From 39423b5afb746230b399fcb6a585faa17e87cfa7 Mon Sep 17 00:00:00 2001 From: Egor Kulin Date: Mon, 27 May 2024 16:20:28 +0000 Subject: [PATCH] Minor changes --- ydb/core/base/id_wrapper.h | 3 +++ .../nodewarden/node_warden_vdisk.cpp | 2 +- ydb/core/mind/bscontroller/config.cpp | 2 +- .../mind/bscontroller/config_fit_groups.cpp | 12 +++++----- ydb/core/mind/bscontroller/disk_metrics.cpp | 5 ++-- ydb/core/mind/bscontroller/group_mapper.cpp | 2 +- .../bscontroller/group_metrics_exchange.cpp | 3 ++- ydb/core/mind/bscontroller/monitoring.cpp | 21 ++++++++-------- .../mind/bscontroller/propose_group_key.cpp | 24 +++++++++---------- ydb/core/mind/bscontroller/scheme.h | 2 +- ydb/core/mind/bscontroller/sys_view.cpp | 4 ++-- .../bscontroller/update_seen_operational.cpp | 4 ++-- ydb/core/mind/bscontroller/virtual_group.cpp | 10 ++++---- 13 files changed, 50 insertions(+), 44 deletions(-) diff --git a/ydb/core/base/id_wrapper.h b/ydb/core/base/id_wrapper.h index f9fc17d634ca..50aa12dfa4a1 100644 --- a/ydb/core/base/id_wrapper.h +++ b/ydb/core/base/id_wrapper.h @@ -16,6 +16,9 @@ template class TIdWrapper { T Raw; public: + + using Type = T; + constexpr TIdWrapper() noexcept : Raw(0) { } diff --git a/ydb/core/blobstorage/nodewarden/node_warden_vdisk.cpp b/ydb/core/blobstorage/nodewarden/node_warden_vdisk.cpp index 7a1fa34dbecb..1ab22f235bf5 100644 --- a/ydb/core/blobstorage/nodewarden/node_warden_vdisk.cpp +++ b/ydb/core/blobstorage/nodewarden/node_warden_vdisk.cpp @@ -215,7 +215,7 @@ namespace NKikimr::NStorage { // for dynamic groups -- start state aggregator if (TGroupID(groupInfo->GroupID).ConfigurationType() == EGroupConfigurationType::Dynamic) { - StartAggregator(vdiskServiceId, groupInfo->GroupID); + StartAggregator(vdiskServiceId, groupInfo->GroupID.GetRawId()); } Y_ABORT_UNLESS(vdisk.ScrubState == TVDiskRecord::EScrubState::IDLE); diff --git a/ydb/core/mind/bscontroller/config.cpp b/ydb/core/mind/bscontroller/config.cpp index 6a420facff49..1337b4f60f29 100644 --- a/ydb/core/mind/bscontroller/config.cpp +++ b/ydb/core/mind/bscontroller/config.cpp @@ -414,7 +414,7 @@ namespace NKikimr::NBsController { for (auto&& [base, overlay] : state.Groups.Diff()) { if (!overlay->second) { const TGroupId groupId = overlay->first; - db.Table().Key(groupId).Delete(); + db.Table().Key(groupId.GetRawId()).Delete(); } } diff --git a/ydb/core/mind/bscontroller/config_fit_groups.cpp b/ydb/core/mind/bscontroller/config_fit_groups.cpp index a8d4eae22ffd..42bda54b02c3 100644 --- a/ydb/core/mind/bscontroller/config_fit_groups.cpp +++ b/ydb/core/mind/bscontroller/config_fit_groups.cpp @@ -69,7 +69,7 @@ namespace NKikimr { for (;;) { // obtain group local id auto& nextGroupId = State.NextGroupId.Unshare(); - const ui32 groupLocalId = nextGroupId ? TGroupID(nextGroupId).GroupLocalID() : 0; + const ui32 groupLocalId = nextGroupId.GetRawId() ? TGroupID(nextGroupId).GroupLocalID() : 0; // create new full group id TGroupID fullGroupId(EGroupConfigurationType::Dynamic, AvailabilityDomainId, groupLocalId); @@ -124,7 +124,7 @@ namespace NKikimr { ui32 lifeCyclePhase = 0; TString mainKeyId = ""; TString encryptedGroupKey = ""; - ui64 groupKeyNonce = groupId; // For the first time use groupId, then use low 32 bits of the + ui64 groupKeyNonce = groupId.GetRawId(); // For the first time use groupId, then use low 32 bits of the // NextGroupKeyNonce to produce high 32 bits of the groupKeyNonce. TGroupInfo *groupInfo = State.Groups.ConstructInplaceNewEntry(groupId, groupId, 1, @@ -193,7 +193,7 @@ namespace NKikimr { TMap replacedSlots; i64 requiredSpace = Min(); - bool sanitizingRequest = (State.SanitizingRequests.find(groupId) != State.SanitizingRequests.end()); + bool sanitizingRequest = (State.SanitizingRequests.find(groupId.GetRawId()) != State.SanitizingRequests.end()); //////////////////////////////////////////////////////////////////////////////////////////////////////// // scan through all VSlots and find matching PDisks @@ -376,9 +376,9 @@ namespace NKikimr { if (!IgnoreGroupFailModelChecks) { // process only groups with changed content; check the failure model if (!checker.CheckFailModelForGroup(failed)) { - throw TExMayLoseData(groupId); + throw TExMayLoseData(groupId.GetRawId()); } else if (!IgnoreDegradedGroupsChecks && checker.IsDegraded(failed)) { - throw TExMayGetDegraded(groupId); + throw TExMayGetDegraded(groupId.GetRawId()); } } @@ -506,7 +506,7 @@ namespace NKikimr { TStackVec groups; for (const auto& [vslotId, vslot] : info.VSlotsOnPDisk) { if (!vslot->IsBeingDeleted()) { - groups.push_back(vslot->GroupId); + groups.push_back(vslot->GroupId.GetRawId()); } } diff --git a/ydb/core/mind/bscontroller/disk_metrics.cpp b/ydb/core/mind/bscontroller/disk_metrics.cpp index 576efc877909..3c8694233403 100644 --- a/ydb/core/mind/bscontroller/disk_metrics.cpp +++ b/ydb/core/mind/bscontroller/disk_metrics.cpp @@ -27,12 +27,13 @@ class TBlobStorageController::TTxUpdateDiskMetrics : public TTransactionBaseVSlots) { if (std::exchange(v->MetricsDirty, false)) { - auto&& key = std::tie(v->GroupId.GetRawId(), v->GroupGeneration, v->RingIdx, v->FailDomainIdx, v->VDiskIdx); + auto groupId = v->GroupId.GetRawId(); + auto&& key = std::tie(groupId, v->GroupGeneration, v->RingIdx, v->FailDomainIdx, v->VDiskIdx); auto value = v->Metrics; value.ClearVDiskId(); db.Table().Key(key).Update(value); Self->SysViewChangedVSlots.insert(vslotId); - Self->SysViewChangedGroups.insert(v->GroupId); + Self->SysViewChangedGroups.insert(v->GroupId.GetRawId()); } } diff --git a/ydb/core/mind/bscontroller/group_mapper.cpp b/ydb/core/mind/bscontroller/group_mapper.cpp index 8a6f86c1dfe3..0aaa2ad11dc9 100644 --- a/ydb/core/mind/bscontroller/group_mapper.cpp +++ b/ydb/core/mind/bscontroller/group_mapper.cpp @@ -1154,6 +1154,6 @@ namespace NKikimr::NBsController { std::optional TGroupMapper::TargetMisplacedVDisk(TGroupId groupId, TGroupMapper::TGroupDefinition& group, TVDiskIdShort vdisk, TForbiddenPDisks forbid, i64 requiredSpace, bool requireOperational, TString& error) { - return Impl->TargetMisplacedVDisk(groupId, group, vdisk, std::move(forbid), requiredSpace, requireOperational, error); + return Impl->TargetMisplacedVDisk(groupId.GetRawId(), group, vdisk, std::move(forbid), requiredSpace, requireOperational, error); } } // NKikimr::NBsController diff --git a/ydb/core/mind/bscontroller/group_metrics_exchange.cpp b/ydb/core/mind/bscontroller/group_metrics_exchange.cpp index 972ba0446de6..681525c3d10a 100644 --- a/ydb/core/mind/bscontroller/group_metrics_exchange.cpp +++ b/ydb/core/mind/bscontroller/group_metrics_exchange.cpp @@ -28,7 +28,8 @@ namespace NKikimr::NBsController { TString s; const bool success = group->GroupMetrics->SerializeToString(&s); Y_DEBUG_ABORT_UNLESS(success); - db.Table().Key(group->ID).Update(s); + typename TGroupId::Type groupId = group->ID.GetRawId(); + db.Table().Key(groupId).Update(s); } } diff --git a/ydb/core/mind/bscontroller/monitoring.cpp b/ydb/core/mind/bscontroller/monitoring.cpp index d199dd2dffd9..808a01a016a8 100644 --- a/ydb/core/mind/bscontroller/monitoring.cpp +++ b/ydb/core/mind/bscontroller/monitoring.cpp @@ -644,24 +644,25 @@ class TBlobStorageController::TTxMonEvent_SetDown : public TTransactionBaseFindGroup(GroupId); + TGroupInfo* group = Self->FindGroup(GroupId.GetRawId()); if (group == nullptr) { - Response = "{\"Error\":\"Group " + ToString(GroupId) + " not found\"}"; + Response = "{\"Error\":\"Group " + ToString(GroupId.GetRawId()) + " not found\"}"; return true; } group->Down = Down; if (Persist) { NIceDb::TNiceDb db(txc.DB); - db.Table().Key(GroupId).Update(Down); + typename TGroupId::Type groupId = GroupId.GetRawId(); + db.Table().Key(groupId).Update(Down); group->PersistedDown = Down; } - Response = "{\"GroupId\":" + ToString(GroupId) + ',' + "\"Down\":" + (Down ? "true" : "false") + "}"; + Response = "{\"GroupId\":" + ToString(GroupId.GetRawId()) + ',' + "\"Down\":" + (Down ? "true" : "false") + "}"; return true; } void Complete(const TActorContext&) override { STLOG(PRI_DEBUG, BS_CONTROLLER, BSCTXMO01, "TBlobStorageController::TTxMonEvent_SetDown", - (GroupId, GroupId), (Down, Down), (Persist, Persist), (Response, Response)); + (GroupId.GetRawId(), GroupId.GetRawId()), (Down, Down), (Persist, Persist), (Response, Response)); TActivationContext::Send(new IEventHandle(Source, Self->SelfId(), new NMon::TEvRemoteJsonInfoRes(Response))); } }; @@ -692,7 +693,7 @@ class TBlobStorageController::TTxMonEvent_GetDown : public TTransactionBaseFindGroup(GroupId)) { + if (TGroupInfo* group = Self->FindGroup(GroupId.GetRawId())) { json = reportGroup(*group); } else { json["Error"] = Sprintf("GroupId# %" PRIu32 " not found", GroupId.GetRawId()); @@ -711,7 +712,7 @@ class TBlobStorageController::TTxMonEvent_GetDown : public TTransactionBaseSelfId(), new NMon::TEvRemoteJsonInfoRes(Response))); } @@ -875,12 +876,12 @@ bool TBlobStorageController::OnRenderAppHtmlPage(NMon::TEvRemoteHttpInfo::TPtr e } else { const TString& page = cgi.Get("page"); if (page == "SetDown") { - TGroupId groupId = FromStringWithDefault(cgi.Get("group"), 0); + 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)); } else if (page == "GetDown") { - TGroupId groupId = FromStringWithDefault(cgi.Get("group"), 0); + ui32 groupId = FromStringWithDefault(cgi.Get("group"), 0); tx.Reset(new TTxMonEvent_GetDown(ev->Sender, groupId, this)); } else if (page == "OperationLog") { tx.Reset(new TTxMonEvent_OperationLog(ev->Sender, cgi, this)); @@ -904,7 +905,7 @@ bool TBlobStorageController::OnRenderAppHtmlPage(NMon::TEvRemoteHttpInfo::TPtr e const ui64 storagePoolId = FromStringWithDefault(cgi.Get("StoragePoolId"), -1); RenderGroupsInStoragePool(str, TBoxStoragePoolId(boxId, storagePoolId)); } else if (page == "GroupDetail") { - const TGroupId groupId = FromStringWithDefault(cgi.Get("GroupId"), -1); + const ui32 groupId = FromStringWithDefault(cgi.Get("GroupId"), -1); RenderGroupDetail(str, groupId); } else if (page == "Scrub") { ScrubState.Render(str); diff --git a/ydb/core/mind/bscontroller/propose_group_key.cpp b/ydb/core/mind/bscontroller/propose_group_key.cpp index 0f54a0bf01ef..2851b80c004c 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 TTransactionBaseGet()->Record; NodeId = proto.GetNodeId(); - GroupId = proto.GetGroupId(); + GroupId = TGroupId(proto.GetGroupId()); LifeCyclePhase = proto.GetLifeCyclePhase(); MainKeyId = proto.GetMainKeyId(); EncryptedGroupKey = proto.GetEncryptedGroupKey(); @@ -35,24 +35,24 @@ class TBlobStorageController::TTxProposeGroupKey : public TTransactionBaseFindGroup(GroupId); - if (TGroupID(GroupId).ConfigurationType() != EGroupConfigurationType::Dynamic) { - STLOG(PRI_CRIT, BS_CONTROLLER, BSCTXPGK01, "Can't propose key for non-dynamic group", (GroupId, GroupId)); + TGroupInfo *group = Self->FindGroup(GroupId.GetRawId()); + 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) { - STLOG(PRI_CRIT, BS_CONTROLLER, BSCTXPGK02, "Can't read group info", (GroupId, GroupId)); + STLOG(PRI_CRIT, BS_CONTROLLER, BSCTXPGK02, "Can't read group info", (GroupId.GetRawId(), GroupId.GetRawId())); } else if (group->EncryptionMode.GetOrElse(0) == 0) { - STLOG(PRI_ERROR, BS_CONTROLLER, BSCTXPGK03, "Group is not encrypted", (GroupId, GroupId)); + STLOG(PRI_ERROR, BS_CONTROLLER, BSCTXPGK03, "Group is not encrypted", (GroupId.GetRawId(), GroupId.GetRawId())); } else if (group->LifeCyclePhase.GetOrElse(0) != TBlobStorageGroupInfo::ELCP_INITIAL) { STLOG(PRI_ERROR, BS_CONTROLLER, BSCTXPGK04, "Group LifeCyclePhase does not match ELCP_INITIAL", - (GroupId, GroupId), (LifeCyclePhase, group->LifeCyclePhase.GetOrElse(0))); + (GroupId.GetRawId(), GroupId.GetRawId()), (LifeCyclePhase, group->LifeCyclePhase.GetOrElse(0))); IsAnotherTxInProgress = (group->LifeCyclePhase.GetOrElse(0) == TBlobStorageGroupInfo::ELCP_IN_TRANSITION); } else if (group->MainKeyVersion.GetOrElse(0) != (MainKeyVersion - 1)) { STLOG(PRI_ERROR, BS_CONTROLLER, BSCTXPGK05, "Group MainKeyVersion does not match required MainKeyVersion", - (GroupId, GroupId), (MainKeyVersion, group->MainKeyVersion.GetOrElse(0)), + (GroupId.GetRawId(), GroupId.GetRawId()), (MainKeyVersion, group->MainKeyVersion.GetOrElse(0)), (RequiredMainKeyVersion, MainKeyVersion - 1)); } else if (EncryptedGroupKey.size() != 32 + sizeof(ui32)) { STLOG(PRI_ERROR, BS_CONTROLLER, BSCTXPGK06, "Group does not accept EncryptedGroupKey size", - (GroupId, GroupId), (EncryptedGroupKeySize, EncryptedGroupKey.size()), + (GroupId.GetRawId(), GroupId.GetRawId()), (EncryptedGroupKeySize, EncryptedGroupKey.size()), (ExpectedEncryptedGroupKeySize, 32 + sizeof(ui32))); } else { Status = prevStatus; // return old status @@ -63,7 +63,7 @@ class TBlobStorageController::TTxProposeGroupKey : public TTransactionBaseFindGroup(GroupId); + TGroupInfo *group = Self->FindGroup(GroupId.GetRawId()); Y_ABORT_UNLESS(group); // the existence of this group must have been checked during ReadStep group->LifeCyclePhase = TBlobStorageGroupInfo::ELCP_IN_TRANSITION; group->MainKeyId = MainKeyId; @@ -109,7 +109,7 @@ class TBlobStorageController::TTxProposeGroupKey : public TTransactionBaseNotifyNodesAwaitingKeysForGroups(GroupId); + Self->NotifyNodesAwaitingKeysForGroups(GroupId.GetRawId()); } } }; diff --git a/ydb/core/mind/bscontroller/scheme.h b/ydb/core/mind/bscontroller/scheme.h index f57c7b3689d3..b59b7adb6ae5 100644 --- a/ydb/core/mind/bscontroller/scheme.h +++ b/ydb/core/mind/bscontroller/scheme.h @@ -49,7 +49,7 @@ struct Schema : NIceDb::Schema { }; struct Group : Table<4> { - struct ID : Column<1, NScheme::NTypeIds::Uint32> { using Type = TIdWrapper; }; // PK + struct ID : Column<1, NScheme::NTypeIds::Uint32> { using Type = TIdWrapper; static constexpr Type Default = TIdWrapper::Zero();}; // PK struct Generation : Column<2, NScheme::NTypeIds::Uint32> {}; struct ErasureSpecies : Column<3, NScheme::NTypeIds::Uint32> { using Type = TErasureType::EErasureSpecies; }; struct Owner : Column<4, NScheme::NTypeIds::Uint64> {}; diff --git a/ydb/core/mind/bscontroller/sys_view.cpp b/ydb/core/mind/bscontroller/sys_view.cpp index f37a03c6a0fa..a18b4c4242f3 100644 --- a/ydb/core/mind/bscontroller/sys_view.cpp +++ b/ydb/core/mind/bscontroller/sys_view.cpp @@ -33,7 +33,7 @@ TGroupId TransformKey(const NKikimrSysView::TGroupKey& key) { } void FillKey(NKikimrSysView::TGroupKey* key, const TGroupId& id) { - key->SetGroupId(id); + key->SetGroupId(id.GetRawId()); } TBoxStoragePoolId TransformKey(const NKikimrSysView::TStoragePoolKey& key) { @@ -326,7 +326,7 @@ void CopyInfo(NKikimrSysView::TPDiskInfo* info, const THolderSetGroupId(vdiskId.GroupID); + pb->SetGroupId(vdiskId.GroupID.GetRawId()); pb->SetGroupGeneration(vdiskId.GroupGeneration); pb->SetFailRealm(vdiskId.FailRealm); pb->SetFailDomain(vdiskId.FailDomain); diff --git a/ydb/core/mind/bscontroller/update_seen_operational.cpp b/ydb/core/mind/bscontroller/update_seen_operational.cpp index 82784d3e0b0a..b94a808b7474 100644 --- a/ydb/core/mind/bscontroller/update_seen_operational.cpp +++ b/ydb/core/mind/bscontroller/update_seen_operational.cpp @@ -17,8 +17,8 @@ class TBlobStorageController::TTxUpdateSeenOperational : public TTransactionBase bool Execute(TTransactionContext &txc, const TActorContext&) override { NIceDb::TNiceDb db(txc.DB); for (const TGroupId groupId : GroupIds) { - db.Table().Key(groupId).Update(true); - Self->SysViewChangedGroups.insert(groupId); + db.Table().Key(groupId.GetRawId()).Update(true); + Self->SysViewChangedGroups.insert(groupId.GetRawId()); } return true; } diff --git a/ydb/core/mind/bscontroller/virtual_group.cpp b/ydb/core/mind/bscontroller/virtual_group.cpp index 274100685b03..21ffb8528b9b 100644 --- a/ydb/core/mind/bscontroller/virtual_group.cpp +++ b/ydb/core/mind/bscontroller/virtual_group.cpp @@ -96,7 +96,7 @@ namespace NKikimr::NBsController { const bool success = config.SerializeToString(&group->BlobDepotConfig.ConstructInPlace()); Y_ABORT_UNLESS(success); - status.AddGroupId(group->ID); + status.AddGroupId(group->ID.GetRawId()); } void TBlobStorageController::TConfigState::ExecuteStep(const NKikimrBlobStorage::TDecommitGroups& cmd, TStatus& /*status*/) { @@ -110,16 +110,16 @@ namespace NKikimr::NBsController { throw TExGroupNotFound(groupId.GetRawId()); } 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); + throw TExError() << "different hive specified for decommitting group" << TErrorParams::GroupId(groupId.GetRawId()); } else if (cmd.HasDatabase() && group->Database && *group->Database != cmd.GetDatabase()) { - throw TExError() << "different database specified for decommitting group" << TErrorParams::GroupId(groupId); + throw TExError() << "different database specified for decommitting group" << TErrorParams::GroupId(groupId.GetRawId()); } else if (cmd.HasHiveId() != group->HiveId.Defined() && cmd.HasDatabase() != group->Database.Defined()) { - throw TExError() << "different hive designator specified for decommitting group" << TErrorParams::GroupId(groupId); + throw TExError() << "different hive designator specified for decommitting group" << TErrorParams::GroupId(groupId.GetRawId()); } // group is already being decommitted -- make this operation idempotent continue; } else if (group->VirtualGroupState) { - throw TExError() << "group is already virtual" << TErrorParams::GroupId(groupId); + throw TExError() << "group is already virtual" << TErrorParams::GroupId(groupId.GetRawId()); } group->DecommitStatus = NKikimrBlobStorage::TGroupDecommitStatus::PENDING;