Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor Kulin committed May 27, 2024
1 parent fa8f6a7 commit 39423b5
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 44 deletions.
3 changes: 3 additions & 0 deletions ydb/core/base/id_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ template <typename T, typename Tag> class TIdWrapper {
T Raw;

public:

using Type = T;

constexpr TIdWrapper() noexcept : Raw(0) {
}

Expand Down
2 changes: 1 addition & 1 deletion ydb/core/blobstorage/nodewarden/node_warden_vdisk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/mind/bscontroller/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ namespace NKikimr::NBsController {
for (auto&& [base, overlay] : state.Groups.Diff()) {
if (!overlay->second) {
const TGroupId groupId = overlay->first;
db.Table<Schema::GroupLatencies>().Key(groupId).Delete();
db.Table<Schema::GroupLatencies>().Key(groupId.GetRawId()).Delete();
}
}

Expand Down
12 changes: 6 additions & 6 deletions ydb/core/mind/bscontroller/config_fit_groups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -193,7 +193,7 @@ namespace NKikimr {
TMap<TVDiskIdShort, TVSlotId> replacedSlots;
i64 requiredSpace = Min<i64>();

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
Expand Down Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -506,7 +506,7 @@ namespace NKikimr {
TStackVec<ui32, 16> groups;
for (const auto& [vslotId, vslot] : info.VSlotsOnPDisk) {
if (!vslot->IsBeingDeleted()) {
groups.push_back(vslot->GroupId);
groups.push_back(vslot->GroupId.GetRawId());
}
}

Expand Down
5 changes: 3 additions & 2 deletions ydb/core/mind/bscontroller/disk_metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ class TBlobStorageController::TTxUpdateDiskMetrics : public TTransactionBase<TBl

for (const auto& [vslotId, v] : Self->VSlots) {
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<Schema::VDiskMetrics>().Key(key).Update<Schema::VDiskMetrics::Metrics>(value);
Self->SysViewChangedVSlots.insert(vslotId);
Self->SysViewChangedGroups.insert(v->GroupId);
Self->SysViewChangedGroups.insert(v->GroupId.GetRawId());
}
}

Expand Down
2 changes: 1 addition & 1 deletion ydb/core/mind/bscontroller/group_mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,6 @@ namespace NKikimr::NBsController {

std::optional<TPDiskId> 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
3 changes: 2 additions & 1 deletion ydb/core/mind/bscontroller/group_metrics_exchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ namespace NKikimr::NBsController {
TString s;
const bool success = group->GroupMetrics->SerializeToString(&s);
Y_DEBUG_ABORT_UNLESS(success);
db.Table<Schema::Group>().Key(group->ID).Update<Schema::Group::Metrics>(s);
typename TGroupId::Type groupId = group->ID.GetRawId();
db.Table<Schema::Group>().Key(groupId).Update<Schema::Group::Metrics>(s);
}
}

Expand Down
21 changes: 11 additions & 10 deletions ydb/core/mind/bscontroller/monitoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,24 +644,25 @@ class TBlobStorageController::TTxMonEvent_SetDown : public TTransactionBase<TBlo
TTxType GetTxType() const override { return NBlobStorageController::TXTYPE_MON_EVENT_SET_DOWN; }

bool Execute(TTransactionContext& txc, const TActorContext&) override {
TGroupInfo* group = Self->FindGroup(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<Schema::Group>().Key(GroupId).Update<Schema::Group::Down>(Down);
typename TGroupId::Type groupId = GroupId.GetRawId();
db.Table<Schema::Group>().Key(groupId).Update<Schema::Group::Down>(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)));
}
};
Expand Down Expand Up @@ -692,7 +693,7 @@ class TBlobStorageController::TTxMonEvent_GetDown : public TTransactionBase<TBlo
};

if (GroupId.GetRawId()) {
if (TGroupInfo* group = Self->FindGroup(GroupId)) {
if (TGroupInfo* group = Self->FindGroup(GroupId.GetRawId())) {
json = reportGroup(*group);
} else {
json["Error"] = Sprintf("GroupId# %" PRIu32 " not found", GroupId.GetRawId());
Expand All @@ -711,7 +712,7 @@ class TBlobStorageController::TTxMonEvent_GetDown : public TTransactionBase<TBlo
}

void Complete(const TActorContext&) override {
STLOG(PRI_DEBUG, BS_CONTROLLER, BSCTXMO02, "TBlobStorageController::TTxMonEvent_GetDown", (GroupId, GroupId),
STLOG(PRI_DEBUG, BS_CONTROLLER, BSCTXMO02, "TBlobStorageController::TTxMonEvent_GetDown", (GroupId.GetRawId(), GroupId.GetRawId()),
(Response, Response));
TActivationContext::Send(new IEventHandle(Source, Self->SelfId(), new NMon::TEvRemoteJsonInfoRes(Response)));
}
Expand Down Expand Up @@ -875,12 +876,12 @@ bool TBlobStorageController::OnRenderAppHtmlPage(NMon::TEvRemoteHttpInfo::TPtr e
} else {
const TString& page = cgi.Get("page");
if (page == "SetDown") {
TGroupId groupId = FromStringWithDefault<TGroupId>(cgi.Get("group"), 0);
ui32 groupId = FromStringWithDefault<ui32>(cgi.Get("group"), 0);
const bool down = FromStringWithDefault<i32>(cgi.Get("down"), 0);
const bool persist = FromStringWithDefault<i32>(cgi.Get("persist"), 0);
tx.Reset(new TTxMonEvent_SetDown(ev->Sender, groupId, down, persist, this));
} else if (page == "GetDown") {
TGroupId groupId = FromStringWithDefault<TGroupId>(cgi.Get("group"), 0);
ui32 groupId = FromStringWithDefault<ui32>(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));
Expand All @@ -904,7 +905,7 @@ bool TBlobStorageController::OnRenderAppHtmlPage(NMon::TEvRemoteHttpInfo::TPtr e
const ui64 storagePoolId = FromStringWithDefault<ui64>(cgi.Get("StoragePoolId"), -1);
RenderGroupsInStoragePool(str, TBoxStoragePoolId(boxId, storagePoolId));
} else if (page == "GroupDetail") {
const TGroupId groupId = FromStringWithDefault<TGroupId>(cgi.Get("GroupId"), -1);
const ui32 groupId = FromStringWithDefault<ui32>(cgi.Get("GroupId"), -1);
RenderGroupDetail(str, groupId);
} else if (page == "Scrub") {
ScrubState.Render(str);
Expand Down
24 changes: 12 additions & 12 deletions ydb/core/mind/bscontroller/propose_group_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TBlobStorageController::TTxProposeGroupKey : public TTransactionBase<TBlob
TEvBlobStorage::TEvControllerProposeGroupKey::TPtr Event;
NKikimrProto::EReplyStatus Status = NKikimrProto::OK;
ui32 NodeId = 0;
ui32 GroupId = 0;
TGroupId GroupId = 0;
ui32 LifeCyclePhase = 0;
TString MainKeyId = "";
TString EncryptedGroupKey = "";
Expand All @@ -23,7 +23,7 @@ class TBlobStorageController::TTxProposeGroupKey : public TTransactionBase<TBlob
{
const auto& proto = Event->Get()->Record;
NodeId = proto.GetNodeId();
GroupId = proto.GetGroupId();
GroupId = TGroupId(proto.GetGroupId());
LifeCyclePhase = proto.GetLifeCyclePhase();
MainKeyId = proto.GetMainKeyId();
EncryptedGroupKey = proto.GetEncryptedGroupKey();
Expand All @@ -35,24 +35,24 @@ class TBlobStorageController::TTxProposeGroupKey : public TTransactionBase<TBlob

void ReadStep() {
const auto prevStatus = std::exchange(Status, NKikimrProto::ERROR); // assume error
TGroupInfo *group = Self->FindGroup(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
Expand All @@ -63,7 +63,7 @@ class TBlobStorageController::TTxProposeGroupKey : public TTransactionBase<TBlob
NIceDb::TNiceDb db(txc.DB);
// Reflect group structure in the database (pass)

TGroupInfo *group = Self->FindGroup(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;
Expand Down Expand Up @@ -109,7 +109,7 @@ class TBlobStorageController::TTxProposeGroupKey : public TTransactionBase<TBlob
}
if (!IsAnotherTxInProgress) {
// Get groupinfo for the group and send it to all whom it may concern.
Self->NotifyNodesAwaitingKeysForGroups(GroupId);
Self->NotifyNodesAwaitingKeysForGroups(GroupId.GetRawId());
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/mind/bscontroller/scheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct Schema : NIceDb::Schema {
};

struct Group : Table<4> {
struct ID : Column<1, NScheme::NTypeIds::Uint32> { using Type = TIdWrapper<ui32, TGroupIdTag>; }; // PK
struct ID : Column<1, NScheme::NTypeIds::Uint32> { using Type = TIdWrapper<ui32, TGroupIdTag>; static constexpr Type Default = TIdWrapper<ui32, TGroupIdTag>::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> {};
Expand Down
4 changes: 2 additions & 2 deletions ydb/core/mind/bscontroller/sys_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -326,7 +326,7 @@ void CopyInfo(NKikimrSysView::TPDiskInfo* info, const THolder<TBlobStorageContro

void SerializeVSlotInfo(NKikimrSysView::TVSlotInfo *pb, const TVDiskID& vdiskId, const NKikimrBlobStorage::TVDiskMetrics& m,
NKikimrBlobStorage::EVDiskStatus status, NKikimrBlobStorage::TVDiskKind::EVDiskKind kind, bool isBeingDeleted) {
pb->SetGroupId(vdiskId.GroupID);
pb->SetGroupId(vdiskId.GroupID.GetRawId());
pb->SetGroupGeneration(vdiskId.GroupGeneration);
pb->SetFailRealm(vdiskId.FailRealm);
pb->SetFailDomain(vdiskId.FailDomain);
Expand Down
4 changes: 2 additions & 2 deletions ydb/core/mind/bscontroller/update_seen_operational.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Schema::Group>().Key(groupId).Update<Schema::Group::SeenOperational>(true);
Self->SysViewChangedGroups.insert(groupId);
db.Table<Schema::Group>().Key(groupId.GetRawId()).Update<Schema::Group::SeenOperational>(true);
Self->SysViewChangedGroups.insert(groupId.GetRawId());
}
return true;
}
Expand Down
10 changes: 5 additions & 5 deletions ydb/core/mind/bscontroller/virtual_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*/) {
Expand All @@ -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;
Expand Down

0 comments on commit 39423b5

Please sign in to comment.