From 9e5dff8951bbf44babf10c1978293bb893c2a145 Mon Sep 17 00:00:00 2001 From: Egor Kulin Date: Wed, 29 May 2024 09:12:07 +0000 Subject: [PATCH] Added IdWrapper for bscontroller, partly for blobstorage, nodewarden, dsproxy --- ydb/core/base/blobstorage.cpp | 4 +-- ydb/core/base/id_wrapper.h | 26 +++++++++------- ydb/core/blob_depot/agent/agent_impl.h | 1 + ydb/core/blob_depot/agent/proxy.cpp | 2 +- ydb/core/blob_depot/agent/query.cpp | 2 +- ydb/core/blob_depot/agent/storage_get.cpp | 2 +- ydb/core/blob_depot/agent/storage_put.cpp | 2 +- ydb/core/blob_depot/agent/storage_range.cpp | 2 +- .../blobstorage/base/blobstorage_vdiskid.cpp | 4 +-- ydb/core/blobstorage/dsproxy/dsproxy.h | 2 +- ydb/core/blobstorage/dsproxy/dsproxy_impl.h | 4 +-- .../blobstorage/dsproxy/dsproxy_patch.cpp | 6 ++-- .../blobstorage/dsproxy/dsproxy_request.cpp | 2 +- .../blobstorage/dsproxy/mock/dsproxy_mock.cpp | 7 +++-- .../blobstorage/dsproxy/mock/dsproxy_mock.h | 4 +-- ydb/core/blobstorage/dsproxy/mock/model.h | 8 ++--- .../groupinfo/blobstorage_groupinfo.cpp | 11 +++---- .../groupinfo/blobstorage_groupinfo.h | 2 +- .../blobstorage/incrhuge/incrhuge_keeper.cpp | 4 ++- ydb/core/blobstorage/nodewarden/defs.h | 1 + ydb/core/blobstorage/nodewarden/distconf.h | 4 +-- .../nodewarden/distconf_generate.cpp | 6 ++-- .../nodewarden/distconf_invoke.cpp | 12 ++++---- .../nodewarden/distconf_validate.cpp | 4 +-- .../nodewarden/node_warden_group.cpp | 4 +-- .../nodewarden/node_warden_group_resolver.cpp | 2 +- .../nodewarden/node_warden_impl.cpp | 6 ++-- .../blobstorage/nodewarden/node_warden_impl.h | 1 + .../nodewarden/node_warden_proxy.cpp | 2 +- .../syncer/blobstorage_syncer_dataserdes.h | 4 +-- ydb/core/cms/cluster_info.cpp | 5 ++-- .../keyvalue_storage_read_request.cpp | 4 +-- .../mind/bscontroller/cmds_storage_pool.cpp | 6 ++-- ydb/core/mind/bscontroller/config.cpp | 18 +++++------ .../mind/bscontroller/config_fit_groups.cpp | 6 ++-- ydb/core/mind/bscontroller/disk_metrics.cpp | 2 +- ydb/core/mind/bscontroller/get_group.cpp | 4 +-- .../bscontroller/group_metrics_exchange.cpp | 6 ++-- ydb/core/mind/bscontroller/impl.h | 4 +-- .../mind/bscontroller/load_everything.cpp | 10 +++---- ydb/core/mind/bscontroller/monitoring.cpp | 12 ++++---- .../mind/bscontroller/propose_group_key.cpp | 6 ++-- ydb/core/mind/bscontroller/register_node.cpp | 10 +++---- .../bscontroller/request_controller_info.cpp | 2 +- ydb/core/mind/bscontroller/select_groups.cpp | 2 +- ydb/core/mind/bscontroller/self_heal.cpp | 10 +++---- ydb/core/mind/bscontroller/stat_processor.cpp | 2 +- ydb/core/mind/bscontroller/sys_view.cpp | 6 ++-- .../bscontroller/update_seen_operational.cpp | 2 +- ydb/core/mind/bscontroller/virtual_group.cpp | 30 +++++++++---------- ydb/core/mind/table_adapter.h | 26 ++++++++++++++-- ydb/core/tablet/tablet_req_rebuildhistory.cpp | 4 +-- ydb/core/tablet_flat/flat_cxx_database.h | 11 +++---- .../columnshard/blobs_action/tier/adapter.cpp | 5 ++-- 54 files changed, 184 insertions(+), 150 deletions(-) diff --git a/ydb/core/base/blobstorage.cpp b/ydb/core/base/blobstorage.cpp index d3bdf790c274..59bfb48fa560 100644 --- a/ydb/core/base/blobstorage.cpp +++ b/ydb/core/base/blobstorage.cpp @@ -46,7 +46,7 @@ bool operator<(const TPDiskCategory x, const TPDiskCategory y) { std::unique_ptr TEvBlobStorage::TEvPut::MakeErrorResponse( NKikimrProto::EReplyStatus status, const TString& errorReason, TGroupId groupId) { - auto res = std::make_unique(status, Id, TStorageStatusFlags(), groupId.GetRawId(), 0.0f); + auto res = std::make_unique(status, Id, TStorageStatusFlags(), groupId, 0.0f); res->ErrorReason = errorReason; return res; } @@ -97,7 +97,7 @@ std::unique_ptr TEvBlobStorage::TEvDiscover:: std::unique_ptr TEvBlobStorage::TEvRange::MakeErrorResponse( NKikimrProto::EReplyStatus status, const TString& errorReason, TGroupId groupId) { - auto res = std::make_unique(status, From, To, groupId.GetRawId()); + auto res = std::make_unique(status, From, To, groupId); res->ErrorReason = errorReason; return res; } diff --git a/ydb/core/base/id_wrapper.h b/ydb/core/base/id_wrapper.h index 50aa12dfa4a1..8f2c40c86754 100644 --- a/ydb/core/base/id_wrapper.h +++ b/ydb/core/base/id_wrapper.h @@ -3,6 +3,7 @@ #include #include #include +#include using TString = TBasicString; class TGroupIdTag; @@ -16,15 +17,14 @@ template class TIdWrapper { T Raw; public: - using Type = T; - - constexpr TIdWrapper() noexcept : Raw(0) { - } + using TTag = Tag; + + constexpr TIdWrapper() noexcept : Raw(0) {} ~TIdWrapper() = default; - TIdWrapper(const T &value) : Raw(value){}; + explicit TIdWrapper(const T &value) : Raw(value) {} TIdWrapper(TIdWrapper &&value) = default; @@ -34,18 +34,20 @@ template class TIdWrapper { TIdWrapper &operator=(TIdWrapper &&value) = default; + TString ToString() const { + return TStringBuilder() << Raw; + } + void CopyToProto(NProtoBuf::Message *message, void (NProtoBuf::Message::*pfn)(T value)) { (message->*pfn)(*this); } static constexpr TIdWrapper FromValue(T value) noexcept { - return TIdWrapper(value); + return TIdWrapper(value); } - static constexpr TIdWrapper Zero() noexcept { - return TIdWrapper(); - } + static constexpr TIdWrapper Zero() noexcept { return TIdWrapper(); } TIdWrapper &operator+=(const T &other) { Raw += other.Raw; @@ -68,10 +70,14 @@ template class TIdWrapper { return old; } - friend std::ostream& operator<<(std::ostream& out, TIdWrapper& id){ + friend std::ostream &operator<<(std::ostream &out, TIdWrapper &id) { return out << id.Raw; } + friend IOutputStream& operator<<(IOutputStream& out, const TIdWrapper& id) { + return out << id.Raw; +} + constexpr auto operator<=>(const TIdWrapper &) const = default; T GetRawId() const { return Raw; } diff --git a/ydb/core/blob_depot/agent/agent_impl.h b/ydb/core/blob_depot/agent/agent_impl.h index dc267c84c19c..bac25b43f922 100644 --- a/ydb/core/blob_depot/agent/agent_impl.h +++ b/ydb/core/blob_depot/agent/agent_impl.h @@ -4,6 +4,7 @@ #include "resolved_value.h" #include +#include namespace NKikimr::NBlobDepot { diff --git a/ydb/core/blob_depot/agent/proxy.cpp b/ydb/core/blob_depot/agent/proxy.cpp index 740885a42ea6..c2ec71ccf358 100644 --- a/ydb/core/blob_depot/agent/proxy.cpp +++ b/ydb/core/blob_depot/agent/proxy.cpp @@ -32,7 +32,7 @@ namespace NKikimr::NBlobDepot { switch (const ui32 type = event->Type()) { case TEvBlobStorage::EvGet: { auto& get = static_cast(*event); - response = get.MakeErrorResponse(NKikimrProto::OK, "proxy has vanished", groupId); + response = get.MakeErrorResponse(NKikimrProto::OK, "proxy has vanished", TIdWrapper(groupId)); auto& r = static_cast(*response); for (size_t i = 0; i < r.ResponseSz; ++i) { r.Responses[i].Status = NKikimrProto::NODATA; diff --git a/ydb/core/blob_depot/agent/query.cpp b/ydb/core/blob_depot/agent/query.cpp index 00e7337f9223..70283088ca1d 100644 --- a/ydb/core/blob_depot/agent/query.cpp +++ b/ydb/core/blob_depot/agent/query.cpp @@ -177,7 +177,7 @@ namespace NKikimr::NBlobDepot { switch (Event->GetTypeRewrite()) { #define XX(TYPE) \ case TEvBlobStorage::TYPE: \ - response = Event->Get()->MakeErrorResponse(status, errorReason, Agent.VirtualGroupId); \ + response = Event->Get()->MakeErrorResponse(status, errorReason, TIdWrapper(Agent.VirtualGroupId)); \ static_cast(*response).ExecutionRelay = std::move(ExecutionRelay); \ break; \ // diff --git a/ydb/core/blob_depot/agent/storage_get.cpp b/ydb/core/blob_depot/agent/storage_get.cpp index b3e6d8c03412..94543d3192a2 100644 --- a/ydb/core/blob_depot/agent/storage_get.cpp +++ b/ydb/core/blob_depot/agent/storage_get.cpp @@ -31,7 +31,7 @@ namespace NKikimr::NBlobDepot { } Response = std::make_unique(NKikimrProto::OK, Request.QuerySize, - Agent.VirtualGroupId); + TIdWrapper(Agent.VirtualGroupId)); AnswersRemain = Request.QuerySize; if (Request.ReaderTabletData) { diff --git a/ydb/core/blob_depot/agent/storage_put.cpp b/ydb/core/blob_depot/agent/storage_put.cpp index 4f2c045f9a6a..33debb07ca6d 100644 --- a/ydb/core/blob_depot/agent/storage_put.cpp +++ b/ydb/core/blob_depot/agent/storage_put.cpp @@ -284,7 +284,7 @@ namespace NKikimr::NBlobDepot { Y_ABORT_UNLESS(!WrittenBeyondBarrier); TBlobStorageQuery::EndWithSuccess(std::make_unique(NKikimrProto::OK, Request.Id, - Agent.GetStorageStatusFlags(), Agent.VirtualGroupId, Agent.GetApproximateFreeSpaceShare())); + Agent.GetStorageStatusFlags(), TIdWrapper(Agent.VirtualGroupId), Agent.GetApproximateFreeSpaceShare())); } ui64 GetTabletId() const override { diff --git a/ydb/core/blob_depot/agent/storage_range.cpp b/ydb/core/blob_depot/agent/storage_range.cpp index e6dcbb5189d0..80f451141cbe 100644 --- a/ydb/core/blob_depot/agent/storage_range.cpp +++ b/ydb/core/blob_depot/agent/storage_range.cpp @@ -24,7 +24,7 @@ namespace NKikimr::NBlobDepot { (U.MustRestoreFirst, Request.MustRestoreFirst), (U.IndexOnly, Request.IsIndexOnly)); Response = std::make_unique(NKikimrProto::OK, Request.From, Request.To, - Agent.VirtualGroupId); + TIdWrapper(Agent.VirtualGroupId)); // issue resolve query TString from = Request.From.AsBinaryString(); diff --git a/ydb/core/blobstorage/base/blobstorage_vdiskid.cpp b/ydb/core/blobstorage/base/blobstorage_vdiskid.cpp index ef3c08c866a1..0feafbd8c680 100644 --- a/ydb/core/blobstorage/base/blobstorage_vdiskid.cpp +++ b/ydb/core/blobstorage/base/blobstorage_vdiskid.cpp @@ -8,7 +8,7 @@ namespace NKikimr { //////////////////////////////////////////////////////////////////////////// // TVDiskID //////////////////////////////////////////////////////////////////////////// - const TVDiskID TVDiskID::InvalidId = TVDiskID((ui32)-1, (ui32)-1, (ui8)-1, (ui8)-1, (ui8)-1); + const TVDiskID TVDiskID::InvalidId = TVDiskID(TGroupId(-1), (ui32)-1, (ui8)-1, (ui8)-1, (ui8)-1); TVDiskID::TVDiskID(TGroupId groupId, ui32 groupGen, TVDiskIdShort vdiskIdShort) : GroupID(groupId) @@ -24,7 +24,7 @@ namespace NKikimr { } bool TVDiskID::SameGroupAndGeneration(const NKikimrBlobStorage::TVDiskID &x) const { - return x.GetGroupID() == GroupID && x.GetGroupGeneration() == GroupGeneration; + return x.GetGroupID() == GroupID.GetRawId() && x.GetGroupGeneration() == GroupGeneration; } bool TVDiskID::SameDisk(const NKikimrBlobStorage::TVDiskID &x) const { diff --git a/ydb/core/blobstorage/dsproxy/dsproxy.h b/ydb/core/blobstorage/dsproxy/dsproxy.h index e407e6c75cba..a85873040550 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy.h +++ b/ydb/core/blobstorage/dsproxy/dsproxy.h @@ -296,7 +296,7 @@ class TBlobStorageGroupRequestActor : public TActor { std::optional group; if (record.HasRecentGroup()) { group = record.GetRecentGroup(); - if (group->GetGroupID() != Info->GroupID || group->GetGroupGeneration() != vdiskId.GroupGeneration) { + if (group->GetGroupID() != Info->GroupID.GetRawId() || group->GetGroupGeneration() != vdiskId.GroupGeneration) { return done(NKikimrProto::ERROR, "incorrect RecentGroup for RACE response"); } } diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_impl.h b/ydb/core/blobstorage/dsproxy/dsproxy_impl.h index 30f5d27a4ae0..64057cab11aa 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_impl.h +++ b/ydb/core/blobstorage/dsproxy/dsproxy_impl.h @@ -114,7 +114,7 @@ class TBlobStorageGroupProxy : public TActorBootstrapped TLogPriorityMuteChecker ErrorStateMuteChecker; TLogPriorityMuteChecker InvalidGroupIdMuteChecker; - bool HasInvalidGroupId() const { return GroupId == Max(); } + bool HasInvalidGroupId() const { return GroupId.GetRawId() == Max(); } void ProcessInitQueue(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -285,7 +285,7 @@ class TBlobStorageGroupProxy : public TActorBootstrapped const NKikimrProto::EReplyStatus status = (!IsEjected || HasInvalidGroupId()) ? NKikimrProto::ERROR : NKikimrProto::NO_GROUP; - auto response = ev->Get()->MakeErrorResponse(status, ErrorDescription, GroupId.GetRawId()); + auto response = ev->Get()->MakeErrorResponse(status, ErrorDescription, GroupId); SetExecutionRelay(*response, std::move(ev->Get()->ExecutionRelay)); NActors::NLog::EPriority priority = CheckPriorityForErrorState(); LOG_LOG_S(*TlsActivationContext, priority, NKikimrServices::BS_PROXY, ExtraLogInfo << "Group# " << GroupId diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_patch.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_patch.cpp index 52833e6e4f82..cb79902f80bf 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_patch.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_patch.cpp @@ -565,7 +565,7 @@ class TBlobStorageGroupPatchRequest : public TBlobStorageGroupRequestActor(OriginalId, 0, OriginalId.BlobSize(), Deadline, NKikimrBlobStorage::AsyncRead); get->Orbit = std::move(Orbit); - if (OriginalGroupId == Info->GroupID) { + if (OriginalGroupId == Info->GroupID.GetRawId()) { SendToProxy(std::move(get), PatchedId.Hash(), Span.GetTraceId()); } else { SendToBSProxy(SelfId(), OriginalGroupId, get.release(), PatchedId.Hash(), Span.GetTraceId()); @@ -811,7 +811,7 @@ class TBlobStorageGroupPatchRequest : public TBlobStorageGroupRequestActorType.ErasureFamily() == TErasureType::ErasureParityBlock || Info->Type.GetErasure() == TErasureType::ErasureNone || Info->Type.GetErasure() == TErasureType::ErasureMirror3dc; - if (IsGoodPatchedBlobId && IsAllowedErasure && UseVPatch && OriginalGroupId == Info->GroupID && !IsSecured) { + if (IsGoodPatchedBlobId && IsAllowedErasure && UseVPatch && OriginalGroupId == Info->GroupID.GetRawId() && !IsSecured) { PATCH_LOG(PRI_DEBUG, BS_PROXY_PATCH, BPPA03, "Start VPatch strategy from bootstrap"); StartVPatch(); } else { @@ -819,7 +819,7 @@ class TBlobStorageGroupPatchRequest : public TBlobStorageGroupRequestActorGroupID), + (IsSameGroup, OriginalGroupId == Info->GroupID.GetRawId()), (IsSecured, IsSecured)); StartFallback(); } diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_request.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_request.cpp index 33abdfd7ef72..8217bcd40edb 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_request.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_request.cpp @@ -91,7 +91,7 @@ namespace NKikimr { << " Group# " << GroupId << " Marker# DSP53"; std::unique_ptr result( - new TEvBlobStorage::TEvPutResult(NKikimrProto::ERROR, ev->Get()->Id, 0, GroupId.GetRawId(), 0.f)); + new TEvBlobStorage::TEvPutResult(NKikimrProto::ERROR, ev->Get()->Id, 0, GroupId, 0.f)); result->ErrorReason = str.Str(); result->ExecutionRelay = std::move(ev->Get()->ExecutionRelay); LOG_ERROR_S(*TlsActivationContext, NKikimrServices::BS_PROXY, diff --git a/ydb/core/blobstorage/dsproxy/mock/dsproxy_mock.cpp b/ydb/core/blobstorage/dsproxy/mock/dsproxy_mock.cpp index 1a39d931f91f..3918ce78dbb1 100644 --- a/ydb/core/blobstorage/dsproxy/mock/dsproxy_mock.cpp +++ b/ydb/core/blobstorage/dsproxy/mock/dsproxy_mock.cpp @@ -10,7 +10,8 @@ namespace NKikimr { class TBlobStorageGroupProxyMockActor : public TActor - { + { + using TGroupId = TIdWrapper; TIntrusivePtr Model; void Handle(TEvBlobStorage::TEvPut::TPtr& ev) { @@ -106,7 +107,7 @@ namespace NKikimr { {} - TBlobStorageGroupProxyMockActor(ui32 groupId) + TBlobStorageGroupProxyMockActor(TGroupId groupId) : TActor(&TBlobStorageGroupProxyMockActor::StateFunc) , Model(MakeIntrusive(groupId)) {} @@ -117,7 +118,7 @@ namespace NKikimr { return new TBlobStorageGroupProxyMockActor(std::move(model)); } - IActor *CreateBlobStorageGroupProxyMockActor(ui32 groupId) { + IActor *CreateBlobStorageGroupProxyMockActor(TIdWrapper groupId) { return new TBlobStorageGroupProxyMockActor(groupId); } diff --git a/ydb/core/blobstorage/dsproxy/mock/dsproxy_mock.h b/ydb/core/blobstorage/dsproxy/mock/dsproxy_mock.h index 5cb37a571127..b06919dfb91d 100644 --- a/ydb/core/blobstorage/dsproxy/mock/dsproxy_mock.h +++ b/ydb/core/blobstorage/dsproxy/mock/dsproxy_mock.h @@ -1,7 +1,7 @@ #pragma once #include "defs.h" - +#include namespace NKikimr { namespace NFake { @@ -9,6 +9,6 @@ namespace NKikimr { } // NFake IActor *CreateBlobStorageGroupProxyMockActor(TIntrusivePtr model); - IActor *CreateBlobStorageGroupProxyMockActor(ui32 groupId); + IActor *CreateBlobStorageGroupProxyMockActor(TIdWrapper groupId); } // NKikimr diff --git a/ydb/core/blobstorage/dsproxy/mock/model.h b/ydb/core/blobstorage/dsproxy/mock/model.h index 59accba10d84..e20fa9b774e3 100644 --- a/ydb/core/blobstorage/dsproxy/mock/model.h +++ b/ydb/core/blobstorage/dsproxy/mock/model.h @@ -8,6 +8,7 @@ namespace NKikimr { namespace NFake { class TProxyDS : public TThrRefBase { + using TGroupId = TIdWrapper; using TTabletId = ui64; using TChannel = ui8; using TGeneration = ui32; @@ -56,10 +57,10 @@ namespace NFake { TMap Blobs; // By default only NKikimrBlobStorage::StatusIsValid is set TStorageStatusFlags StorageStatusFlags = TStorageStatusFlags(NKikimrBlobStorage::StatusIsValid); - const ui32 GroupId; + const TGroupId GroupId; public: - TProxyDS(ui32 groupId = 0) + TProxyDS(TGroupId groupId = TGroupId::Zero()) : GroupId(groupId) {} @@ -265,8 +266,7 @@ namespace NFake { Y_ABORT_UNLESS(from.TabletID() == to.TabletID()); Y_ABORT_UNLESS(from.Channel() == to.Channel()); - Y_ABORT_UNLESS(from.TabletID() == msg->TabletId); - + Y_ABORT_UNLESS(from.TabletID() == msg->TabletId); auto result = std::make_unique(NKikimrProto::OK, from, to, GroupId); auto process = [&](const TLogoBlobID& id, const TString& buffer) { diff --git a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp index 03e24d92267f..d746f2b33a7c 100644 --- a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp +++ b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp @@ -563,7 +563,7 @@ TBlobStorageGroupInfo::TDynamicInfo::TDynamicInfo(TGroupId groupId, ui32 groupGe //////////////////////////////////////////////////////////////////////////// TBlobStorageGroupInfo::TBlobStorageGroupInfo(TBlobStorageGroupType gtype, ui32 numVDisksPerFailDomain, ui32 numFailDomains, ui32 numFailRealms, const TVector *vdiskIds, EEncryptionMode encryptionMode, - ELifeCyclePhase lifeCyclePhase, TCypherKey key, ui32 groupId) + ELifeCyclePhase lifeCyclePhase, TCypherKey key, TGroupId groupId) : GroupID(groupId) , GroupGeneration(1) , Type(gtype) @@ -638,7 +638,7 @@ TIntrusivePtr TBlobStorageGroupInfo::Parse(const NKikimrB auto erasure = (TBlobStorageGroupType::EErasureSpecies)group.GetErasureSpecies(); TBlobStorageGroupType type(erasure); TBlobStorageGroupInfo::TTopology topology(type); - TBlobStorageGroupInfo::TDynamicInfo dyn(group.GetGroupID(), group.GetGroupGeneration()); + TBlobStorageGroupInfo::TDynamicInfo dyn(TGroupId(group.GetGroupID()), group.GetGroupGeneration()); topology.FailRealms.resize(group.RingsSize()); for (ui32 ringIdx = 0; ringIdx < group.RingsSize(); ++ringIdx) { const auto& realm = group.GetRings(ringIdx); @@ -917,7 +917,8 @@ TString TBlobStorageGroupInfo::ToString() const { TVDiskID VDiskIDFromVDiskID(const NKikimrBlobStorage::TVDiskID &x) { - return TVDiskID(x.GetGroupID(), x.GetGroupGeneration(), x.GetRing(), x.GetDomain(), x.GetVDisk()); + using TGroupId = TIdWrapper; + return TVDiskID(TGroupId(x.GetGroupID()), x.GetGroupGeneration(), x.GetRing(), x.GetDomain(), x.GetVDisk()); } void VDiskIDFromVDiskID(const TVDiskID &id, NKikimrBlobStorage::TVDiskID *proto) { @@ -956,8 +957,8 @@ TVDiskID VDiskIDFromString(TString str, bool* isGenerationSet) { } groupGeneration = IntFromString(parts[1]); } - - return TVDiskID(IntFromString(parts[0]), + using TGroupId = TIdWrapper; + return TVDiskID(TGroupId(IntFromString(parts[0])), groupGeneration, IntFromString(parts[2]), IntFromString(parts[3]), diff --git a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.h b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.h index 8d89c80ad576..fbda4b952348 100644 --- a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.h +++ b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.h @@ -312,7 +312,7 @@ class TBlobStorageGroupInfo : public TThrRefBase { explicit TBlobStorageGroupInfo(TBlobStorageGroupType gtype, ui32 numVDisksPerFailDomain = 1, ui32 numFailDomains = 0, ui32 numFailRealms = 1, const TVector *vdiskIds = nullptr, EEncryptionMode encryptionMode = EEM_ENC_V1, ELifeCyclePhase lifeCyclePhase = ELCP_IN_USE, - TCypherKey key = TCypherKey((const ui8*)"TestKey", 8), ui32 groupId = 0); + TCypherKey key = TCypherKey((const ui8*)"TestKey", 8), TGroupId groupId = TGroupId::Zero()); TBlobStorageGroupInfo(std::shared_ptr topology, TDynamicInfo&& rti, TString storagePoolName, TMaybe acceptedScope, NPDisk::EDeviceType deviceType); diff --git a/ydb/core/blobstorage/incrhuge/incrhuge_keeper.cpp b/ydb/core/blobstorage/incrhuge/incrhuge_keeper.cpp index 6ad6e6d7fb90..d31150df067f 100644 --- a/ydb/core/blobstorage/incrhuge/incrhuge_keeper.cpp +++ b/ydb/core/blobstorage/incrhuge/incrhuge_keeper.cpp @@ -3,6 +3,7 @@ #include "incrhuge_keeper_recovery_scan.h" #include #include +#include #include #include #include @@ -26,8 +27,9 @@ namespace NKikimr { } void TKeeper::Bootstrap(const TActorContext& ctx) { + using TGroupId = TIdWrapper; // send yard init message - TVDiskID myVDiskId(~0, ~0, 'H', 'I', 'K'); + TVDiskID myVDiskId(TGroupId(~0), ~0, 'H', 'I', 'K'); ctx.Send(State.Settings.PDiskActorId, new NPDisk::TEvYardInit(State.Settings.InitOwnerRound, myVDiskId, State.Settings.PDiskGuid, ctx.SelfID)); Become(&TKeeper::StateFunc); diff --git a/ydb/core/blobstorage/nodewarden/defs.h b/ydb/core/blobstorage/nodewarden/defs.h index 14d5d32154f8..29d2d5737c94 100644 --- a/ydb/core/blobstorage/nodewarden/defs.h +++ b/ydb/core/blobstorage/nodewarden/defs.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/ydb/core/blobstorage/nodewarden/distconf.h b/ydb/core/blobstorage/nodewarden/distconf.h index 51c03b9205d7..683c40adee3f 100644 --- a/ydb/core/blobstorage/nodewarden/distconf.h +++ b/ydb/core/blobstorage/nodewarden/distconf.h @@ -578,7 +578,7 @@ namespace NKikimr::NStorage { continue; } const auto vdiskId = VDiskIDFromVDiskID(vdisk.GetVDiskID()); - const auto it = groups.find(vdiskId.GroupID); + const auto it = groups.find(vdiskId.GroupID.GetRawId()); if (it == groups.end()) { return makeError(TStringBuilder() << "VDisk " << vdiskId << " does not match any static group"); } @@ -604,7 +604,7 @@ namespace NKikimr::NStorage { const auto [begin, end] = confirm.equal_range(key); for (auto it = begin; it != end; ++it) { const TVDiskID& vdiskId = it->second; - TGroupRecord& group = groups.at(vdiskId.GroupID); + TGroupRecord& group = groups.at(vdiskId.GroupID.GetRawId()); group.Confirmed |= {&group.Info->GetTopology(), vdiskId}; } }); diff --git a/ydb/core/blobstorage/nodewarden/distconf_generate.cpp b/ydb/core/blobstorage/nodewarden/distconf_generate.cpp index 010c35b3aa69..57b4c9e70f2f 100644 --- a/ydb/core/blobstorage/nodewarden/distconf_generate.cpp +++ b/ydb/core/blobstorage/nodewarden/distconf_generate.cpp @@ -212,7 +212,7 @@ namespace NKikimr::NStorage { for (const auto& vdisk : ss.GetVDisks()) { const TVDiskID vdiskId = VDiskIDFromVDiskID(vdisk.GetVDiskID()); - if (vdiskId.GroupID == groupId) { + if (vdiskId.GroupID.GetRawId() == groupId) { vdiskLocations.emplace(vdiskId, vdisk.GetVDiskLocation()); } } @@ -428,7 +428,7 @@ namespace NKikimr::NStorage { for (size_t i = 0; i < sSet->VDisksSize(); ++i) { const auto& vdisk = sSet->GetVDisks(i); const TVDiskID vdiskId = VDiskIDFromVDiskID(vdisk.GetVDiskID()); - if (vdiskId.GroupID != groupId || vdisk.GetEntityStatus() == NKikimrBlobStorage::EEntityStatus::DESTROY) { + if (vdiskId.GroupID.GetRawId() != groupId || vdisk.GetEntityStatus() == NKikimrBlobStorage::EEntityStatus::DESTROY) { continue; } auto *m = sSet->MutableVDisks(i); @@ -483,7 +483,7 @@ namespace NKikimr::NStorage { sLoc->SetPDiskGuid(pdisk.GetPDiskGuid()); auto *sDisk = sSet->AddVDisks(); - VDiskIDFromVDiskID(TVDiskID(groupId, groupGeneration, vdiskId), sDisk->MutableVDiskID()); + VDiskIDFromVDiskID(TVDiskID(TIdWrapper(groupId), groupGeneration, vdiskId), sDisk->MutableVDiskID()); sDisk->SetVDiskKind(NKikimrBlobStorage::TVDiskKind::Default); sDisk->MutableVDiskLocation()->CopyFrom(*sLoc); if (const auto it = donors.find(vdiskId); it != donors.end()) { diff --git a/ydb/core/blobstorage/nodewarden/distconf_invoke.cpp b/ydb/core/blobstorage/nodewarden/distconf_invoke.cpp index 524fe84e320f..495d31547672 100644 --- a/ydb/core/blobstorage/nodewarden/distconf_invoke.cpp +++ b/ydb/core/blobstorage/nodewarden/distconf_invoke.cpp @@ -181,7 +181,7 @@ namespace NKikimr::NStorage { bool found = false; const TVDiskID vdiskId = VDiskIDFromVDiskID(cmd.GetVDiskId()); for (const auto& group : Self->StorageConfig->GetBlobStorageConfig().GetServiceSet().GetGroups()) { - if (group.GetGroupID() == vdiskId.GroupID) { + if (group.GetGroupID() == vdiskId.GroupID.GetRawId()) { if (group.GetGroupGeneration() != vdiskId.GroupGeneration) { return FinishWithError(TResult::ERROR, TStringBuilder() << "group generation mismatch" << " GroupId# " << group.GetGroupID() @@ -313,11 +313,11 @@ namespace NKikimr::NStorage { // scan failed disks according to BS_CONTROLLER's data TBlobStorageGroupInfo::TGroupVDisks failedVDisks(&GroupInfo->GetTopology()); for (const auto& vslot : BaseConfig->GetVSlot()) { - if (vslot.GetGroupId() != vdiskId.GroupID || vslot.GetGroupGeneration() != vdiskId.GroupGeneration) { + if (vslot.GetGroupId() != vdiskId.GroupID.GetRawId() || vslot.GetGroupGeneration() != vdiskId.GroupGeneration) { continue; } if (!vslot.GetReady()) { - const TVDiskID vdiskId(vslot.GetGroupId(), vslot.GetGroupGeneration(), vslot.GetFailRealmIdx(), + const TVDiskID vdiskId(TIdWrapper(vslot.GetGroupId()), vslot.GetGroupGeneration(), vslot.GetFailRealmIdx(), vslot.GetFailDomainIdx(), vslot.GetVDiskIdx()); failedVDisks |= {&GroupInfo->GetTopology(), vdiskId}; } @@ -374,9 +374,9 @@ namespace NKikimr::NStorage { } for (const auto& group : ss.GetGroups()) { - if (group.GetGroupID() == vdiskId.GroupID) { + if (group.GetGroupID() == vdiskId.GroupID.GetRawId()) { try { - Self->AllocateStaticGroup(&config, vdiskId.GroupID, vdiskId.GroupGeneration + 1, + Self->AllocateStaticGroup(&config, vdiskId.GroupID.GetRawId(), vdiskId.GroupGeneration + 1, TBlobStorageGroupType((TBlobStorageGroupType::EErasureSpecies)group.GetErasureSpecies()), settings.GetGeometry(), settings.GetPDiskFilter(), replacedDisks, forbid, maxSlotSize, &BaseConfig.value(), cmd.GetConvertToDonor(), cmd.GetIgnoreVSlotQuotaCheck(), @@ -430,7 +430,7 @@ namespace NKikimr::NStorage { ui32 actualGroupGeneration = 0; for (const auto& group : ss->GetGroups()) { - if (group.GetGroupID() == vdiskId.GroupID) { + if (group.GetGroupID() == vdiskId.GroupID.GetRawId()) { actualGroupGeneration = group.GetGroupGeneration(); break; } diff --git a/ydb/core/blobstorage/nodewarden/distconf_validate.cpp b/ydb/core/blobstorage/nodewarden/distconf_validate.cpp index ff9b0b05f9bd..37c7e58d5b70 100644 --- a/ydb/core/blobstorage/nodewarden/distconf_validate.cpp +++ b/ydb/core/blobstorage/nodewarden/distconf_validate.cpp @@ -60,7 +60,7 @@ namespace NKikimr::NStorage { THashSet changedGroups; for (const auto& vslot : proposed.GetVDisks()) { TVDiskID vdiskId = VDiskIDFromVDiskID(vslot.GetVDiskID()); - const auto groupIt = proposedGroupGens.find(vdiskId.GroupID); + const auto groupIt = proposedGroupGens.find(vdiskId.GroupID.GetRawId()); if (groupIt == proposedGroupGens.end() || groupIt->second != vdiskId.GroupGeneration) { continue; } @@ -318,7 +318,7 @@ namespace NKikimr::NStorage { const ui32 vslotId = l.GetVDiskSlotID(); const ui64 pdiskGuid = l.GetPDiskGuid(); - const TVDiskID vdiskId(groupId, groupGen, failRealmIdx, failDomainIdx, vdiskIdx); + const TVDiskID vdiskId(TIdWrapper(groupId), groupGen, failRealmIdx, failDomainIdx, vdiskIdx); if (const auto it = vdisks.find(vdiskId); it == vdisks.end()) { return TStringBuilder() << "vslot with specific VDiskID is not found" diff --git a/ydb/core/blobstorage/nodewarden/node_warden_group.cpp b/ydb/core/blobstorage/nodewarden/node_warden_group.cpp index 0e9a8e208cd2..89d59490e455 100644 --- a/ydb/core/blobstorage/nodewarden/node_warden_group.cpp +++ b/ydb/core/blobstorage/nodewarden/node_warden_group.cpp @@ -272,11 +272,11 @@ namespace NKikimr::NStorage { void TNodeWarden::Handle(TEvBlobStorage::TEvUpdateGroupInfo::TPtr ev) { auto *msg = ev->Get(); bool fromResolver = false; - if (const auto it = Groups.find(msg->GroupId); it != Groups.end() && ev->Sender == it->second.GroupResolver) { + if (const auto it = Groups.find(msg->GroupId.GetRawId()); it != Groups.end() && ev->Sender == it->second.GroupResolver) { it->second.GroupResolver = {}; fromResolver = true; } - ApplyGroupInfo(msg->GroupId, msg->GroupGeneration, msg->GroupInfo ? &*msg->GroupInfo : nullptr, false, fromResolver); + ApplyGroupInfo(msg->GroupId.GetRawId(), msg->GroupGeneration, msg->GroupInfo ? &*msg->GroupInfo : nullptr, false, fromResolver); } void TNodeWarden::HandleGetGroup(TAutoPtr ev) { diff --git a/ydb/core/blobstorage/nodewarden/node_warden_group_resolver.cpp b/ydb/core/blobstorage/nodewarden/node_warden_group_resolver.cpp index 51a3e1248f4d..3f2073f3dad0 100644 --- a/ydb/core/blobstorage/nodewarden/node_warden_group_resolver.cpp +++ b/ydb/core/blobstorage/nodewarden/node_warden_group_resolver.cpp @@ -258,7 +258,7 @@ namespace NKikimr::NStorage { if (auto *result = GetResultingGroupInfo()) { STLOG(PRI_INFO, BS_NODE, NW86, "TGroupResolverActor::ProcessResultAndFinish", (GroupId, GroupId), (Result, *result)); - Send(MakeBlobStorageNodeWardenID(SelfId().NodeId()), new TEvBlobStorage::TEvUpdateGroupInfo(GroupId, + Send(MakeBlobStorageNodeWardenID(SelfId().NodeId()), new TEvBlobStorage::TEvUpdateGroupInfo(TIdWrapper(GroupId), result->GetGroupGeneration(), *result)); PassAway(); } else { // restart from the beginning diff --git a/ydb/core/blobstorage/nodewarden/node_warden_impl.cpp b/ydb/core/blobstorage/nodewarden/node_warden_impl.cpp index 682bf9cd9421..65f8d8cfa3a1 100644 --- a/ydb/core/blobstorage/nodewarden/node_warden_impl.cpp +++ b/ydb/core/blobstorage/nodewarden/node_warden_impl.cpp @@ -625,12 +625,12 @@ void TNodeWarden::Handle(TEvStatusUpdate::TPtr ev) { const auto& r = vdisk.RuntimeData; const auto& info = r->GroupInfo; - if (const ui32 groupId = info->GroupID; TGroupID(groupId).ConfigurationType() == EGroupConfigurationType::Static) { + if (const ui32 groupId = info->GroupID.GetRawId(); TGroupID(groupId).ConfigurationType() == EGroupConfigurationType::Static) { for (const auto& item : StorageConfig.GetBlobStorageConfig().GetServiceSet().GetVDisks()) { const TVDiskID vdiskId = VDiskIDFromVDiskID(item.GetVDiskID()); - if (vdiskId.GroupID == groupId && info->GetTopology().GetOrderNumber(vdiskId) == r->OrderNumber && + if (vdiskId.GroupID.GetRawId() == groupId && info->GetTopology().GetOrderNumber(vdiskId) == r->OrderNumber && item.HasDonorMode() && item.GetEntityStatus() != NKikimrBlobStorage::EEntityStatus::DESTROY) { - SendDropDonorQuery(vslotId.NodeId, vslotId.PDiskId, vslotId.VDiskSlotId, TVDiskID(groupId, 0, + SendDropDonorQuery(vslotId.NodeId, vslotId.PDiskId, vslotId.VDiskSlotId, TVDiskID(TIdWrapper(groupId), 0, info->GetVDiskId(r->OrderNumber))); break; } diff --git a/ydb/core/blobstorage/nodewarden/node_warden_impl.h b/ydb/core/blobstorage/nodewarden/node_warden_impl.h index 985680808f02..31714a1868b5 100644 --- a/ydb/core/blobstorage/nodewarden/node_warden_impl.h +++ b/ydb/core/blobstorage/nodewarden/node_warden_impl.h @@ -5,6 +5,7 @@ #include "node_warden_events.h" #include +#include #include #include diff --git a/ydb/core/blobstorage/nodewarden/node_warden_proxy.cpp b/ydb/core/blobstorage/nodewarden/node_warden_proxy.cpp index b770dd5a4ce8..71e413696d68 100644 --- a/ydb/core/blobstorage/nodewarden/node_warden_proxy.cpp +++ b/ydb/core/blobstorage/nodewarden/node_warden_proxy.cpp @@ -22,7 +22,7 @@ void TNodeWarden::StartLocalProxy(ui32 groupId) { if (EnableProxyMock) { // create mock proxy - proxy.reset(CreateBlobStorageGroupProxyMockActor(groupId)); + proxy.reset(CreateBlobStorageGroupProxyMockActor(TIdWrapper(groupId))); } else if (auto info = NeedGroupInfo(groupId)) { if (info->BlobDepotId) { TActorId proxyActorId; diff --git a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_dataserdes.h b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_dataserdes.h index de460612dc28..f25b4975c245 100644 --- a/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_dataserdes.h +++ b/ydb/core/blobstorage/vdisk/syncer/blobstorage_syncer_dataserdes.h @@ -55,7 +55,7 @@ class TSyncNeighbors::TOldDes { private: IInputStream &Str; - TGroupId GroupId = 0; + TGroupId GroupId = TGroupId::Zero(); ui32 GroupGeneration = 0; }; @@ -94,7 +94,7 @@ class TSyncNeighbors::TSer { NKikimrVDiskData::TSyncerEntryPoint LocalProto; NKikimrVDiskData::TSyncerEntryPoint *Proto = nullptr; IOutputStream *Str = nullptr; - TGroupId GroupId = 0; + TGroupId GroupId = TGroupId::Zero(); ui32 GroupGeneration = 0; }; diff --git a/ydb/core/cms/cluster_info.cpp b/ydb/core/cms/cluster_info.cpp index fc7b39695ca6..1c7b176341bd 100644 --- a/ydb/core/cms/cluster_info.cpp +++ b/ydb/core/cms/cluster_info.cpp @@ -3,6 +3,7 @@ #include "node_checkers.h" #include +#include #include #include @@ -277,7 +278,7 @@ bool TVDiskInfo::NameToId(const TString &name, TVDiskID &id) if (size != static_cast(name.size())) return false; - id = TVDiskID(group, gen, ring, domain, vdisk); + id = TVDiskID(TIdWrapper(group), gen, ring, domain, vdisk); return true; } @@ -502,7 +503,7 @@ void TClusterInfo::AddVDisk(const NKikimrBlobStorage::TBaseConfig::TVSlot &info) return; } - TVDiskID vdiskId(info.GetGroupId(), + TVDiskID vdiskId(TIdWrapper(info.GetGroupId()), info.GetGroupGeneration(), info.GetFailRealmIdx(), info.GetFailDomainIdx(), diff --git a/ydb/core/keyvalue/keyvalue_storage_read_request.cpp b/ydb/core/keyvalue/keyvalue_storage_read_request.cpp index d93ac00aa091..fbdcafcb4dbe 100644 --- a/ydb/core/keyvalue/keyvalue_storage_read_request.cpp +++ b/ydb/core/keyvalue/keyvalue_storage_read_request.cpp @@ -226,11 +226,11 @@ class TKeyValueStorageReadRequest : public TActorBootstrappedCookie]; - if (result->GroupId != batch.GroupId) { + if (result->GroupId.GetRawId() != batch.GroupId) { STLOG_WITH_ERROR_DESCRIPTION(ErrorDescription, NLog::PRI_ERROR, NKikimrServices::KEYVALUE, KV318, "Received EvGetResult from an unexpected storage group.", (KeyValue, TabletInfo->TabletID), - (GroupId, result->GroupId), + (GroupId, result->GroupId.GetRawId()), (ExpecetedGroupId, batch.GroupId), (Status, result->Status), (Deadline, IntermediateResult->Deadline.MilliSeconds()), diff --git a/ydb/core/mind/bscontroller/cmds_storage_pool.cpp b/ydb/core/mind/bscontroller/cmds_storage_pool.cpp index 374a58808851..7a82651ace91 100644 --- a/ydb/core/mind/bscontroller/cmds_storage_pool.cpp +++ b/ydb/core/mind/bscontroller/cmds_storage_pool.cpp @@ -342,11 +342,11 @@ namespace NKikimr::NBsController { void TBlobStorageController::TConfigState::ExecuteStep(const NKikimrBlobStorage::TReassignGroupDisk& cmd, NKikimrBlobStorage::TConfigResponse::TStatus& /*status*/) { // find matching TVSlotInfo entity - const TVDiskID vdiskId(cmd.GetGroupId(), cmd.GetGroupGeneration(), cmd.GetFailRealmIdx(), + const TVDiskID vdiskId(TGroupId(cmd.GetGroupId()), cmd.GetGroupGeneration(), cmd.GetFailRealmIdx(), cmd.GetFailDomainIdx(), cmd.GetVDiskIdx()); // validate group and generation - const TGroupInfo *group = Groups.Find(cmd.GetGroupId()); + const TGroupInfo *group = Groups.Find(TGroupId(cmd.GetGroupId())); if (!group) { throw TExError() << "GroupId# " << cmd.GetGroupId() << " not found"; } else if (group->Generation != cmd.GetGroupGeneration()) { @@ -701,7 +701,7 @@ namespace NKikimr::NBsController { void TBlobStorageController::TConfigState::ExecuteStep(const NKikimrBlobStorage::TSanitizeGroup& cmd, NKikimrBlobStorage::TConfigResponse::TStatus& /*status*/) { ui32 groupId = cmd.GetGroupId(); SanitizingRequests.emplace(groupId); - const TGroupInfo *group = Groups.Find(groupId); + const TGroupInfo *group = Groups.Find(TGroupId(groupId)); if (group) { Fit.PoolsAndGroups.emplace(group->StoragePoolId, groupId); } else { diff --git a/ydb/core/mind/bscontroller/config.cpp b/ydb/core/mind/bscontroller/config.cpp index 1337b4f60f29..f0bbeb271b59 100644 --- a/ydb/core/mind/bscontroller/config.cpp +++ b/ydb/core/mind/bscontroller/config.cpp @@ -266,7 +266,7 @@ namespace NKikimr::NBsController { const TNodeId nodeId = kv.first; NKikimrBlobStorage::TNodeWardenServiceSet &service = *Services[nodeId].MutableServiceSet(); NKikimrBlobStorage::TGroupInfo &item = *service.AddGroups(); - item.SetGroupID(groupId); + item.SetGroupID(groupId.GetRawId()); item.SetEntityStatus(NKikimrBlobStorage::DESTROY); } } @@ -395,9 +395,9 @@ namespace NKikimr::NBsController { for (auto&& [base, overlay] : state.Groups.Diff()) { using Table = Schema::GroupStoragePool; if (!overlay->second) { - db.Table().Key(overlay->first).Delete(); + db.Table
().Key(overlay->first.GetRawId()).Delete(); } else if (!base || base->second->StoragePoolId != overlay->second->StoragePoolId) { - db.Table
().Key(overlay->first).Update( + db.Table
().Key(overlay->first.GetRawId()).Update( std::get<0>(overlay->second->StoragePoolId), std::get<1>(overlay->second->StoragePoolId)); } @@ -422,14 +422,14 @@ namespace NKikimr::NBsController { for (auto&& [base, overlay] : state.VSlots.Diff()) { if (!overlay->second || (base && overlay->second->GroupGeneration != base->second->GroupGeneration)) { const TVDiskID& vdiskId = base->second->GetVDiskId(); - db.Table().Key(vdiskId.GroupID, vdiskId.GroupGeneration, vdiskId.FailRealm, + db.Table().Key(vdiskId.GroupID.GetRawId(), vdiskId.GroupGeneration, vdiskId.FailRealm, vdiskId.FailDomain, vdiskId.VDisk).Delete(); } } // write down NextGroupId if it has changed if (state.NextGroupId.Changed()) { - db.Table().Key(true).Update(state.NextGroupId.Get()); + db.Table().Key(true).Update(state.NextGroupId.Get().GetRawId()); } if (state.NextStoragePoolId.Changed()) { db.Table().Key(true).Update(state.NextStoragePoolId.Get()); @@ -438,7 +438,7 @@ namespace NKikimr::NBsController { db.Table().Key(true).Update(state.SerialManagementStage.Get()); } if (state.NextVirtualGroupId.Changed()) { - db.Table().Key(true).Update(state.NextVirtualGroupId.Get()); + db.Table().Key(true).Update(state.NextVirtualGroupId.Get().GetRawId()); } CommitSelfHealUpdates(state); @@ -956,7 +956,7 @@ namespace NKikimr::NBsController { void TBlobStorageController::Serialize(NKikimrBlobStorage::TBaseConfig::TVSlot *pb, const TVSlotInfo &vslot, const TVSlotFinder& finder) { Serialize(pb->MutableVSlotId(), vslot.VSlotId); - pb->SetGroupId(vslot.GroupId); + pb->SetGroupId(vslot.GroupId.GetRawId()); pb->SetGroupGeneration(vslot.GroupGeneration); pb->SetVDiskKind(NKikimrBlobStorage::TVDiskKind::EVDiskKind_Name(vslot.Kind)); pb->SetFailRealmIdx(vslot.RingIdx); @@ -980,7 +980,7 @@ namespace NKikimr::NBsController { } void TBlobStorageController::Serialize(NKikimrBlobStorage::TBaseConfig::TGroup *pb, const TGroupInfo &group) { - pb->SetGroupId(group.ID); + pb->SetGroupId(group.ID.GetRawId()); pb->SetGroupGeneration(group.Generation); pb->SetErasureSpecies(TBlobStorageGroupType::ErasureSpeciesName(group.ErasureSpecies)); for (const TVSlotInfo *vslot : group.VDisksInGroup) { @@ -1059,7 +1059,7 @@ namespace NKikimr::NBsController { void TBlobStorageController::SerializeGroupInfo(NKikimrBlobStorage::TGroupInfo *group, const TGroupInfo& groupInfo, const TString& storagePoolName, const TMaybe& scopeId) { - group->SetGroupID(groupInfo.ID); + group->SetGroupID(groupInfo.ID.GetRawId()); group->SetGroupGeneration(groupInfo.Generation); group->SetStoragePoolName(storagePoolName); diff --git a/ydb/core/mind/bscontroller/config_fit_groups.cpp b/ydb/core/mind/bscontroller/config_fit_groups.cpp index 42bda54b02c3..7d5113ed906f 100644 --- a/ydb/core/mind/bscontroller/config_fit_groups.cpp +++ b/ydb/core/mind/bscontroller/config_fit_groups.cpp @@ -54,7 +54,7 @@ namespace NKikimr { for (ui64 reserve = 0; reserve < min || (reserve - min) * 1000000 / Max(1, total) < part; ++reserve, ++total) { TGroupMapper::TGroupDefinition group; try { - AllocateOrSanitizeGroup(0, group, {}, {}, 0, false, &TGroupGeometryInfo::AllocateGroup); + AllocateOrSanitizeGroup(TGroupId::Zero(), group, {}, {}, 0, false, &TGroupGeometryInfo::AllocateGroup); } catch (const TExFitGroupError&) { throw TExError() << "group reserve constraint hit"; } @@ -77,10 +77,10 @@ namespace NKikimr { ++nextFullGroupId; // write down NextGroupId - nextGroupId = nextFullGroupId.GetRaw(); + nextGroupId = TGroupId(nextFullGroupId.GetRaw()); // exit if there is no collision - groupId = fullGroupId.GetRaw(); + groupId = TGroupId(fullGroupId.GetRaw()); if (!State.Groups.Find(groupId)) { break; } diff --git a/ydb/core/mind/bscontroller/disk_metrics.cpp b/ydb/core/mind/bscontroller/disk_metrics.cpp index 3c8694233403..3f33ece06d41 100644 --- a/ydb/core/mind/bscontroller/disk_metrics.cpp +++ b/ydb/core/mind/bscontroller/disk_metrics.cpp @@ -33,7 +33,7 @@ class TBlobStorageController::TTxUpdateDiskMetrics : public TTransactionBase().Key(key).Update(value); Self->SysViewChangedVSlots.insert(vslotId); - Self->SysViewChangedGroups.insert(v->GroupId.GetRawId()); + Self->SysViewChangedGroups.insert(v->GroupId); } } diff --git a/ydb/core/mind/bscontroller/get_group.cpp b/ydb/core/mind/bscontroller/get_group.cpp index c9af06f6f17b..43cc87f93ca2 100644 --- a/ydb/core/mind/bscontroller/get_group.cpp +++ b/ydb/core/mind/bscontroller/get_group.cpp @@ -35,8 +35,8 @@ class TBlobStorageController::TTxGetGroup : public TTransactionBaseReadGroups(groupIDsToRead, true, Response.get(), NodeId); auto& node = Self->GetNode(NodeId); - for (TGroupId groupId : v) { - node.GroupsRequested.insert(groupId); + for (ui32 groupId : v) { + node.GroupsRequested.insert(TGroupId(groupId)); Self->GroupToNode.emplace(groupId, NodeId); } diff --git a/ydb/core/mind/bscontroller/group_metrics_exchange.cpp b/ydb/core/mind/bscontroller/group_metrics_exchange.cpp index 681525c3d10a..0bbb27481abf 100644 --- a/ydb/core/mind/bscontroller/group_metrics_exchange.cpp +++ b/ydb/core/mind/bscontroller/group_metrics_exchange.cpp @@ -22,7 +22,7 @@ namespace NKikimr::NBsController { NIceDb::TNiceDb db(txc.DB); for (NKikimrBlobStorage::TGroupMetrics& item : *record.MutableGroupMetrics()) { - if (TGroupInfo *group = Self->FindGroup(item.GetGroupId())) { + if (TGroupInfo *group = Self->FindGroup(TGroupId(item.GetGroupId()))) { group->GroupMetrics = std::move(item); TString s; @@ -36,8 +36,8 @@ namespace NKikimr::NBsController { if (record.GroupsToQuerySize()) { Response.reset(new TEvBlobStorage::TEvControllerGroupMetricsExchange); auto& outRecord = Response->Record; - for (const TGroupId groupId : record.GetGroupsToQuery()) { - if (TGroupInfo *group = Self->FindGroup(groupId)) { + for (const ui32 groupId : record.GetGroupsToQuery()) { + if (TGroupInfo *group = Self->FindGroup(TGroupId(groupId))) { auto *item = outRecord.AddGroupMetrics(); item->SetGroupId(group->ID.GetRawId()); group->FillInGroupParameters(item->MutableGroupParameters()); diff --git a/ydb/core/mind/bscontroller/impl.h b/ydb/core/mind/bscontroller/impl.h index 6b86ce7c055e..d94c46134724 100644 --- a/ydb/core/mind/bscontroller/impl.h +++ b/ydb/core/mind/bscontroller/impl.h @@ -1476,8 +1476,8 @@ class TBlobStorageController : public TActor, public TTa THashMap GroupLookup; TMap> IndexGroupSpeciesToGroup; TMap Nodes; - Schema::Group::ID::Type NextGroupID = 0; - Schema::Group::ID::Type NextVirtualGroupId = 0; + Schema::Group::ID::Type NextGroupID = Schema::Group::ID::Type::Zero(); + Schema::Group::ID::Type NextVirtualGroupId = Schema::Group::ID::Type::Zero(); Schema::State::NextStoragePoolId::Type NextStoragePoolId = 0; ui32 DefaultMaxSlots = 0; ui32 PDiskSpaceMarginPromille = 0; diff --git a/ydb/core/mind/bscontroller/load_everything.cpp b/ydb/core/mind/bscontroller/load_everything.cpp index 570027d6de3b..42bda097900e 100644 --- a/ydb/core/mind/bscontroller/load_everything.cpp +++ b/ydb/core/mind/bscontroller/load_everything.cpp @@ -69,8 +69,8 @@ class TBlobStorageController::TTxLoadEverything : public TTransactionBaseNextGroupID = state.GetValue(); - Self->NextVirtualGroupId = state.GetValueOrDefault(); + Self->NextGroupID = TGroupId(state.GetValue()); + Self->NextVirtualGroupId = TGroupId(state.GetValueOrDefault()); Self->NextStoragePoolId = state.GetValue(); Self->NextOperationLogIndex = state.GetValueOrDefault(1); Self->DefaultMaxSlots = state.GetValue(); @@ -120,7 +120,7 @@ class TBlobStorageController::TTxLoadEverything : public TTransactionBase(); const auto boxId = groupStoragePool.GetValue(); const auto storagePoolId = groupStoragePool.GetValue(); - const bool inserted = groupToStoragePool.try_emplace(groupId, boxId, storagePoolId).second; + const bool inserted = groupToStoragePool.try_emplace(TGroupId(groupId), boxId, storagePoolId).second; Y_ABORT_UNLESS(inserted); Self->StoragePoolGroups.emplace(TBoxStoragePoolId(boxId, storagePoolId), groupId); if (!groupStoragePool.Next()) { @@ -408,7 +408,7 @@ class TBlobStorageController::TTxLoadEverything : public TTransactionBase(), table.GetValue(), + const TVDiskID key(TGroupId(table.GetValue()), table.GetValue(), table.GetValue(), table.GetValue(), table.GetValue()); if (TVSlotInfo *slot = Self->FindVSlot(key)) { slot->Metrics = table.GetValueOrDefault(); @@ -430,7 +430,7 @@ class TBlobStorageController::TTxLoadEverything : public TTransactionBase(); + const TGroupId groupId = TGroupId(groupLatencies.GetValue()); if (TGroupInfo *groupInfo = Self->FindGroup(groupId)) { if (groupLatencies.HaveValue()) { groupInfo->LatencyStats.PutTabletLog = TDuration::MicroSeconds(groupLatencies.GetValue()); diff --git a/ydb/core/mind/bscontroller/monitoring.cpp b/ydb/core/mind/bscontroller/monitoring.cpp index 808a01a016a8..29b724e04794 100644 --- a/ydb/core/mind/bscontroller/monitoring.cpp +++ b/ydb/core/mind/bscontroller/monitoring.cpp @@ -421,7 +421,7 @@ class TBlobStorageController::TTxMonEvent_HealthEvents case NKikimrBlobStorage::TConfigRequest::TCommand::kReassignGroupDisk: { const auto& cmd = q.GetReassignGroupDisk(); - const TVDiskID vdiskId(cmd.GetGroupId(), cmd.GetGroupGeneration(), + const TVDiskID vdiskId(TGroupId(cmd.GetGroupId()), cmd.GetGroupGeneration(), cmd.GetFailRealmIdx(), cmd.GetFailDomainIdx(), cmd.GetVDiskIdx()); std::optional pdiskId; @@ -644,7 +644,7 @@ class TBlobStorageController::TTxMonEvent_SetDown : public TTransactionBaseFindGroup(GroupId.GetRawId()); + TGroupInfo* group = Self->FindGroup(GroupId); if (group == nullptr) { Response = "{\"Error\":\"Group " + ToString(GroupId.GetRawId()) + " not found\"}"; return true; @@ -693,7 +693,7 @@ class TBlobStorageController::TTxMonEvent_GetDown : public TTransactionBaseFindGroup(GroupId.GetRawId())) { + if (TGroupInfo* group = Self->FindGroup(GroupId)) { json = reportGroup(*group); } else { json["Error"] = Sprintf("GroupId# %" PRIu32 " not found", GroupId.GetRawId()); @@ -879,10 +879,10 @@ bool TBlobStorageController::OnRenderAppHtmlPage(NMon::TEvRemoteHttpInfo::TPtr e ui32 groupId = FromStringWithDefault(cgi.Get("group"), 0); const bool down = FromStringWithDefault(cgi.Get("down"), 0); const bool persist = FromStringWithDefault(cgi.Get("persist"), 0); - tx.Reset(new TTxMonEvent_SetDown(ev->Sender, groupId, down, persist, this)); + tx.Reset(new TTxMonEvent_SetDown(ev->Sender, TGroupId(groupId), down, persist, this)); } else if (page == "GetDown") { ui32 groupId = FromStringWithDefault(cgi.Get("group"), 0); - tx.Reset(new TTxMonEvent_GetDown(ev->Sender, groupId, this)); + tx.Reset(new TTxMonEvent_GetDown(ev->Sender, TGroupId(groupId), this)); } else if (page == "OperationLog") { tx.Reset(new TTxMonEvent_OperationLog(ev->Sender, cgi, this)); } else if (page == "OperationLogEntry") { @@ -906,7 +906,7 @@ bool TBlobStorageController::OnRenderAppHtmlPage(NMon::TEvRemoteHttpInfo::TPtr e RenderGroupsInStoragePool(str, TBoxStoragePoolId(boxId, storagePoolId)); } else if (page == "GroupDetail") { const ui32 groupId = FromStringWithDefault(cgi.Get("GroupId"), -1); - RenderGroupDetail(str, groupId); + RenderGroupDetail(str, TGroupId(groupId)); } else if (page == "Scrub") { ScrubState.Render(str); } else if (page == "InternalTables") { diff --git a/ydb/core/mind/bscontroller/propose_group_key.cpp b/ydb/core/mind/bscontroller/propose_group_key.cpp index 2851b80c004c..7628f677c911 100644 --- a/ydb/core/mind/bscontroller/propose_group_key.cpp +++ b/ydb/core/mind/bscontroller/propose_group_key.cpp @@ -8,7 +8,7 @@ class TBlobStorageController::TTxProposeGroupKey : public TTransactionBaseFindGroup(GroupId.GetRawId()); + TGroupInfo *group = Self->FindGroup(GroupId); if (TGroupID(GroupId.GetRawId()).ConfigurationType() != EGroupConfigurationType::Dynamic) { STLOG(PRI_CRIT, BS_CONTROLLER, BSCTXPGK01, "Can't propose key for non-dynamic group", (GroupId.GetRawId(), GroupId.GetRawId())); } else if (!group) { @@ -63,7 +63,7 @@ class TBlobStorageController::TTxProposeGroupKey : public TTransactionBaseFindGroup(GroupId.GetRawId()); + TGroupInfo *group = Self->FindGroup(GroupId); Y_ABORT_UNLESS(group); // the existence of this group must have been checked during ReadStep group->LifeCyclePhase = TBlobStorageGroupInfo::ELCP_IN_TRANSITION; group->MainKeyId = MainKeyId; diff --git a/ydb/core/mind/bscontroller/register_node.cpp b/ydb/core/mind/bscontroller/register_node.cpp index 35e568b3d5e2..fe25443ed90b 100644 --- a/ydb/core/mind/bscontroller/register_node.cpp +++ b/ydb/core/mind/bscontroller/register_node.cpp @@ -286,7 +286,7 @@ class TBlobStorageController::TTxRegisterNode if (startedGroups.size() <= Self->GroupMap.size() / 10) { for (const auto& p : startedGroups) { - processGroup(p, Self->FindGroup(p.first)); + processGroup(p, Self->FindGroup(TGroupId(p.first))); } } else { auto started = startedGroups.begin(); @@ -296,8 +296,8 @@ class TBlobStorageController::TTxRegisterNode TGroupInfo *group = nullptr; // scan through groups until we find matching one - for (; groupIt != Self->GroupMap.end() && groupIt->first <= started->first; ++groupIt) { - if (groupIt->first == started->first) { + for (; groupIt != Self->GroupMap.end() && groupIt->first.GetRawId() <= started->first; ++groupIt) { + if (groupIt->first.GetRawId() == started->first) { group = groupIt->second.Get(); } } @@ -333,7 +333,7 @@ class TBlobStorageController::TTxRegisterNode db.Table().Key(nodeId).Update(node.LastConnectTimestamp); for (ui32 groupId : record.GetGroups()) { - node.GroupsRequested.insert(groupId); + node.GroupsRequested.insert(TGroupId(groupId)); Self->GroupToNode.emplace(groupId, nodeId); } @@ -374,7 +374,7 @@ class TBlobStorageController::TTxUpdateNodeDisconnectTimestamp void TBlobStorageController::ReadGroups(TSet& groupIDsToRead, bool discard, TEvBlobStorage::TEvControllerNodeServiceSetUpdate *result, TNodeId nodeId) { for (auto it = groupIDsToRead.begin(); it != groupIDsToRead.end(); ) { - const TGroupId groupId = *it; + const TGroupId groupId = TGroupId(*it); TGroupInfo *group = FindGroup(groupId); if (group || discard) { NKikimrBlobStorage::TNodeWardenServiceSet *serviceSetProto = result->Record.MutableServiceSet(); diff --git a/ydb/core/mind/bscontroller/request_controller_info.cpp b/ydb/core/mind/bscontroller/request_controller_info.cpp index 9ac95127bc98..e7cb85103735 100644 --- a/ydb/core/mind/bscontroller/request_controller_info.cpp +++ b/ydb/core/mind/bscontroller/request_controller_info.cpp @@ -42,7 +42,7 @@ class TBlobStorageController::TTxRequestControllerInfo : public TTransactionBase }; if (requestRecord.HasGroupId()) { - if (TGroupInfo *group = Self->FindGroup(requestRecord.GetGroupId())) { + if (TGroupInfo *group = Self->FindGroup(TGroupId(requestRecord.GetGroupId()))) { processGroup(group); } } else { diff --git a/ydb/core/mind/bscontroller/select_groups.cpp b/ydb/core/mind/bscontroller/select_groups.cpp index d2fd77976047..38ef019f1a1e 100644 --- a/ydb/core/mind/bscontroller/select_groups.cpp +++ b/ydb/core/mind/bscontroller/select_groups.cpp @@ -116,7 +116,7 @@ void TBlobStorageController::ProcessSelectGroupsQueueItem(TListFillInGroupParameters(&g); if (!hasResources()) { // any of PDisks will do diff --git a/ydb/core/mind/bscontroller/self_heal.cpp b/ydb/core/mind/bscontroller/self_heal.cpp index 59d73626a844..d0db7de33d5c 100644 --- a/ydb/core/mind/bscontroller/self_heal.cpp +++ b/ydb/core/mind/bscontroller/self_heal.cpp @@ -170,7 +170,7 @@ namespace NKikimr::NBsController { if (VDiskToReplace) { ev->SelfHeal = true; auto *cmd = request->AddCommand()->MutableReassignGroupDisk(); - cmd->SetGroupId(VDiskToReplace->GroupID); + cmd->SetGroupId(VDiskToReplace->GroupID.GetRawId()); cmd->SetGroupGeneration(VDiskToReplace->GroupGeneration); cmd->SetFailRealmIdx(VDiskToReplace->FailRealm); cmd->SetFailDomainIdx(VDiskToReplace->FailDomain); @@ -178,7 +178,7 @@ namespace NKikimr::NBsController { } else { ev->GroupLayoutSanitizer = true; auto *cmd = request->AddCommand()->MutableSanitizeGroup(); - cmd->SetGroupId(GroupId); + cmd->SetGroupId(GroupId.GetRawId()); } Send(ControllerId, ev.Release()); @@ -930,7 +930,7 @@ namespace NKikimr::NBsController { const auto& settings = bsConfig.GetAutoconfigSettings(); const auto& ss = bsConfig.GetServiceSet(); for (const auto& group : ss.GetGroups()) { - auto& content = sh->GroupsToUpdate[group.GetGroupID()]; + auto& content = sh->GroupsToUpdate[TGroupId(group.GetGroupID())]; const TBlobStorageGroupType gtype(static_cast(group.GetErasureSpecies())); content = TEvControllerUpdateSelfHealInfo::TGroupContent{ .Generation = group.GetGroupGeneration(), @@ -938,9 +938,9 @@ namespace NKikimr::NBsController { .Geometry = std::make_shared(gtype, settings.GetGeometry()), }; - const TVDiskID vdiskId(group.GetGroupID(), group.GetGroupGeneration(), 0, 0, 0); + const TVDiskID vdiskId(TGroupId(group.GetGroupID()), group.GetGroupGeneration(), 0, 0, 0); for (auto it = StaticVDiskMap.lower_bound(vdiskId); it != StaticVDiskMap.end() && - it->first.GroupID == group.GetGroupID() && + it->first.GroupID.GetRawId() == group.GetGroupID() && it->first.GroupGeneration == group.GetGroupGeneration(); ++it) { const TVSlotId vslotId = it->second; auto& vdiskInfo = content->VDisks[it->first]; diff --git a/ydb/core/mind/bscontroller/stat_processor.cpp b/ydb/core/mind/bscontroller/stat_processor.cpp index 723a25073d72..42a3972b2b60 100644 --- a/ydb/core/mind/bscontroller/stat_processor.cpp +++ b/ydb/core/mind/bscontroller/stat_processor.cpp @@ -77,7 +77,7 @@ namespace NKikimr::NBsController { // apply new report auto& record = ev->Get()->Record; for (const NKikimrBlobStorage::TEvGroupStatReport& item : record.GetPerGroupReport()) { - const TGroupId groupId = item.GetGroupId(); + const TGroupId groupId = TGroupId(item.GetGroupId()); auto it = Groups.find(groupId); if (it != Groups.end()) { it->second.Update(item, now, groupId, GroupCleanupSchedule); diff --git a/ydb/core/mind/bscontroller/sys_view.cpp b/ydb/core/mind/bscontroller/sys_view.cpp index a18b4c4242f3..8919160e915f 100644 --- a/ydb/core/mind/bscontroller/sys_view.cpp +++ b/ydb/core/mind/bscontroller/sys_view.cpp @@ -29,7 +29,7 @@ void FillKey(NKikimrSysView::TVSlotKey* key, const TVSlotId& id) { } TGroupId TransformKey(const NKikimrSysView::TGroupKey& key) { - return key.GetGroupId(); + return TGroupId(key.GetGroupId()); } void FillKey(NKikimrSysView::TGroupKey* key, const TGroupId& id) { @@ -469,10 +469,10 @@ void TBlobStorageController::UpdateSystemViews() { if (const auto& bsConfig = StorageConfig.GetBlobStorageConfig(); bsConfig.HasServiceSet()) { const auto& ss = bsConfig.GetServiceSet(); for (const auto& group : ss.GetGroups()) { - if (!SysViewChangedGroups.count(group.GetGroupID())) { + if (!SysViewChangedGroups.count(TGroupId(group.GetGroupID()))) { continue; } - auto *pb = &state.Groups[group.GetGroupID()]; + auto *pb = &state.Groups[TGroupId(group.GetGroupID())]; pb->SetGeneration(group.GetGroupGeneration()); pb->SetEncryptionMode(group.GetEncryptionMode()); pb->SetLifeCyclePhase(group.GetLifeCyclePhase()); diff --git a/ydb/core/mind/bscontroller/update_seen_operational.cpp b/ydb/core/mind/bscontroller/update_seen_operational.cpp index b94a808b7474..69a1136bf800 100644 --- a/ydb/core/mind/bscontroller/update_seen_operational.cpp +++ b/ydb/core/mind/bscontroller/update_seen_operational.cpp @@ -18,7 +18,7 @@ class TBlobStorageController::TTxUpdateSeenOperational : public TTransactionBase NIceDb::TNiceDb db(txc.DB); for (const TGroupId groupId : GroupIds) { db.Table().Key(groupId.GetRawId()).Update(true); - Self->SysViewChangedGroups.insert(groupId.GetRawId()); + Self->SysViewChangedGroups.insert(groupId); } return true; } diff --git a/ydb/core/mind/bscontroller/virtual_group.cpp b/ydb/core/mind/bscontroller/virtual_group.cpp index 21ffb8528b9b..762682f525ab 100644 --- a/ydb/core/mind/bscontroller/virtual_group.cpp +++ b/ydb/core/mind/bscontroller/virtual_group.cpp @@ -66,7 +66,7 @@ namespace NKikimr::NBsController { auto& pool = pools.at(storagePoolId); // create entry in group table - auto *group = Groups.ConstructInplaceNewEntry(groupId.GetRaw(), groupId.GetRaw(), 0u, 0u, + auto *group = Groups.ConstructInplaceNewEntry(TGroupId(groupId.GetRaw()), TGroupId(groupId.GetRaw()), 0u, 0u, TBlobStorageGroupType::ErasureNone, 0u, NKikimrBlobStorage::TVDiskKind::Default, pool.EncryptionMode.GetOrElse(TBlobStorageGroupInfo::EEM_NONE), TBlobStorageGroupInfo::ELCP_INITIAL, TString(), TString(), 0u, 0u, false, false, storagePoolId, 0u, 0u, 0u); @@ -104,22 +104,22 @@ namespace NKikimr::NBsController { throw TExError() << "TDecommitGroups.HiveId/Database is not specified"; } - for (const TGroupId groupId : cmd.GetGroupIds()) { - TGroupInfo *group = Groups.FindForUpdate(groupId); + for (const ui32 groupId : cmd.GetGroupIds()) { + TGroupInfo *group = Groups.FindForUpdate(TGroupId(groupId)); if (!group) { - throw TExGroupNotFound(groupId.GetRawId()); + throw TExGroupNotFound(groupId); } else if (group->DecommitStatus != NKikimrBlobStorage::TGroupDecommitStatus::NONE) { if (cmd.HasHiveId() && group->HiveId && *group->HiveId != cmd.GetHiveId()) { - throw TExError() << "different hive specified for decommitting group" << TErrorParams::GroupId(groupId.GetRawId()); + throw TExError() << "different hive specified for decommitting group" << TErrorParams::GroupId(groupId); } else if (cmd.HasDatabase() && group->Database && *group->Database != cmd.GetDatabase()) { - throw TExError() << "different database specified for decommitting group" << TErrorParams::GroupId(groupId.GetRawId()); + throw TExError() << "different database specified for decommitting group" << TErrorParams::GroupId(groupId); } else if (cmd.HasHiveId() != group->HiveId.Defined() && cmd.HasDatabase() != group->Database.Defined()) { - throw TExError() << "different hive designator specified for decommitting group" << TErrorParams::GroupId(groupId.GetRawId()); + throw TExError() << "different hive designator specified for decommitting group" << TErrorParams::GroupId(groupId); } // group is already being decommitted -- make this operation idempotent continue; } else if (group->VirtualGroupState) { - throw TExError() << "group is already virtual" << TErrorParams::GroupId(groupId.GetRawId()); + throw TExError() << "group is already virtual" << TErrorParams::GroupId(groupId); } group->DecommitStatus = NKikimrBlobStorage::TGroupDecommitStatus::PENDING; @@ -130,7 +130,7 @@ namespace NKikimr::NBsController { group->CalculateGroupStatus(); NKikimrBlobDepot::TBlobDepotConfig config; - config.SetVirtualGroupId(groupId.GetRawId()); + config.SetVirtualGroupId(groupId); config.SetIsDecommittingGroup(true); auto *profiles = config.MutableChannelProfiles(); @@ -189,16 +189,16 @@ namespace NKikimr::NBsController { } void TBlobStorageController::TConfigState::ExecuteStep(const NKikimrBlobStorage::TCancelVirtualGroup& cmd, TStatus& /*status*/) { - const TGroupId groupId = cmd.GetGroupId(); + const TGroupId groupId = TGroupId(cmd.GetGroupId()); TGroupInfo *group = Groups.FindForUpdate(groupId); if (!group) { throw TExGroupNotFound(groupId.GetRawId()); } else if (!group->VirtualGroupState) { - throw TExError() << "group is not virtual" << TErrorParams::GroupId(groupId); + throw TExError() << "group is not virtual" << TErrorParams::GroupId(groupId.GetRawId()); } else if (auto s = group->VirtualGroupState; s != NKikimrBlobStorage::EVirtualGroupState::NEW && s != NKikimrBlobStorage::EVirtualGroupState::CREATE_FAILED) { - throw TExError() << "group is not in new/error state" << TErrorParams::GroupId(groupId); + throw TExError() << "group is not in new/error state" << TErrorParams::GroupId(groupId.GetRawId()); } else if (auto s = group->DecommitStatus; s != NKikimrBlobStorage::TGroupDecommitStatus::NONE && s != NKikimrBlobStorage::TGroupDecommitStatus::PENDING) { - throw TExError() << "group decommit status is not NONE/PENDING" << TErrorParams::GroupId(groupId); + throw TExError() << "group decommit status is not NONE/PENDING" << TErrorParams::GroupId(groupId.GetRawId()); } else { group->DecommitStatus = NKikimrBlobStorage::TGroupDecommitStatus::NONE; group->VirtualGroupState = NKikimrBlobStorage::EVirtualGroupState::DELETING; @@ -908,7 +908,7 @@ namespace NKikimr::NBsController { void Action(TConfigState& state) { const ui32 groupId = Ev->Get()->Record.GetGroupId(); - TGroupInfo *group = state.Groups.FindForUpdate(groupId); + TGroupInfo *group = state.Groups.FindForUpdate(TGroupId(groupId)); if (!group) { std::tie(Status, ErrorReason) = std::make_tuple(NKikimrProto::ERROR, "group not found"); } else if (group->DecommitStatus == NKikimrBlobStorage::TGroupDecommitStatus::DONE) { @@ -922,7 +922,7 @@ namespace NKikimr::NBsController { group->VDisksInGroup.clear(); group->DecommitStatus = NKikimrBlobStorage::TGroupDecommitStatus::DONE; group->Topology = std::make_shared(group->Topology->GType, 0, 0, 0); - state.GroupContentChanged.insert(groupId); + state.GroupContentChanged.insert(TGroupId(groupId)); } STLOG(PRI_INFO, BS_CONTROLLER, BSCVG10, "decommission update processed", (Status, Status), diff --git a/ydb/core/mind/table_adapter.h b/ydb/core/mind/table_adapter.h index 338146b76c59..64c103470b06 100644 --- a/ydb/core/mind/table_adapter.h +++ b/ydb/core/mind/table_adapter.h @@ -33,6 +33,23 @@ namespace NKikimr { template struct TGetTableKeyColumn> : TGetTableKeyColumnImpl {}; + template + struct HasGetRawId : std::false_type {}; + + template + struct HasGetRawId().GetRawId())>> : std::true_type {}; + + template + auto GetValue(T& item) -> std::enable_if_t::value, decltype(item.GetRawId())> { + return item.GetRawId(); + } + + template + auto GetValue(T& item) -> std::enable_if_t::value, T> { + return item; + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // KEY MAPPER //////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -43,7 +60,7 @@ namespace NKikimr { template static auto PrepareKeyTuple(const std::tuple *items, std::tuple &&tuple) { - TMaybe::Type> value(std::get(*items)); + TMaybe::Type> value(GetValue(std::get(*items))); return TTupleKeyMapper::PrepareKeyTuple(items, std::tuple_cat(std::forward>(tuple), std::make_tuple(std::move(value)))); } @@ -104,6 +121,11 @@ namespace NKikimr { return std::make_tuple(item); } + template + auto WrapTuple(const T &item, std::enable_if_t>>* = nullptr) { + return std::make_tuple(item); + } + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CELL //////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -123,7 +145,7 @@ namespace NKikimr { template inline void Cast(const TIdWrapper& from, TMaybe& to){ - to.ConstructInPlace(from); + to.ConstructInPlace(from.GetRawId()); } template diff --git a/ydb/core/tablet/tablet_req_rebuildhistory.cpp b/ydb/core/tablet/tablet_req_rebuildhistory.cpp index dab15a83cfdf..407d4bd56693 100644 --- a/ydb/core/tablet/tablet_req_rebuildhistory.cpp +++ b/ydb/core/tablet/tablet_req_rebuildhistory.cpp @@ -589,8 +589,8 @@ class TTabletReqRebuildHistoryGraph : public TActorBootstrappedGroupId)] += response.Buffer.size(); - GroupReadOps[std::make_pair(response.Id.Channel(), msg->GroupId)] += 1; + GroupReadBytes[std::make_pair(response.Id.Channel(), msg->GroupId.GetRawId())] += response.Buffer.size(); + GroupReadOps[std::make_pair(response.Id.Channel(), msg->GroupId.GetRawId())] += 1; break; case NKikimrProto::NODATA: BLOG_W("TTabletReqRebuildHistoryGraph::CheckReferences - NODATA for blob " << response.Id, "TRRH07"); diff --git a/ydb/core/tablet_flat/flat_cxx_database.h b/ydb/core/tablet_flat/flat_cxx_database.h index f22541e95911..9a146283b12a 100644 --- a/ydb/core/tablet_flat/flat_cxx_database.h +++ b/ydb/core/tablet_flat/flat_cxx_database.h @@ -774,13 +774,10 @@ struct Schema { return *this; } - auto Key(typename KeyColumns::Type... keyValues) { - return KeyOperations(*Database, keyValues...); - } - - auto Key(const KeyValuesType& keyValues) { - return KeyOperations(*Database, keyValues); - } + template + auto Key(Keys&&... keyValues) { + return KeyOperations(*Database, std::forward(keyValues)...); + } template auto Range(Keys... keyValues) { diff --git a/ydb/core/tx/columnshard/blobs_action/tier/adapter.cpp b/ydb/core/tx/columnshard/blobs_action/tier/adapter.cpp index 9d94dafe939d..6db97f3e7ebc 100644 --- a/ydb/core/tx/columnshard/blobs_action/tier/adapter.cpp +++ b/ydb/core/tx/columnshard/blobs_action/tier/adapter.cpp @@ -26,11 +26,12 @@ std::unique_ptr TRepliesAdapter::RebuildReplyEvent(std::uni TLogoBlobID logoBlobId; TString error; Y_ABORT_UNLESS(ev->Key); + using TGroupId = TIdWrapper; AFL_VERIFY(TLogoBlobID::Parse(logoBlobId, *ev->Key, error))("error", error)("str_blob_id", *ev->Key); if (ev->IsSuccess()) { - return std::make_unique(NKikimrProto::EReplyStatus::OK, logoBlobId, 0, Max(), 0, StorageId); + return std::make_unique(NKikimrProto::EReplyStatus::OK, logoBlobId, 0, TGroupId(Max()), 0, StorageId); } else { - return std::make_unique(NKikimrProto::EReplyStatus::ERROR, logoBlobId, 0, Max(), 0, StorageId); + return std::make_unique(NKikimrProto::EReplyStatus::ERROR, logoBlobId, 0, TGroupId(Max()), 0, StorageId); } }