aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexvru <alexvru@ydb.tech>2023-01-16 21:58:30 +0300
committeralexvru <alexvru@ydb.tech>2023-01-16 21:58:30 +0300
commita22e2d277cf7a5eb716738d3d29772f222675f6d (patch)
treeed23eec5cf7cbbc65a015fc8ae07b9e1eb32559e
parent328635a6bd949596c49a33c9c2b67d00cc2704db (diff)
downloadydb-a22e2d277cf7a5eb716738d3d29772f222675f6d.tar.gz
Some BlobDepot minor fixes
-rw-r--r--ydb/core/blob_depot/agent/storage_range.cpp27
-rw-r--r--ydb/core/blob_depot/data_resolve.cpp2
-rw-r--r--ydb/core/blobstorage/dsproxy/dsproxy.h2
-rw-r--r--ydb/core/blobstorage/dsproxy/dsproxy_assimilate.cpp2
-rw-r--r--ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp2
-rw-r--r--ydb/core/mind/bscontroller/impl.h2
-rw-r--r--ydb/core/mind/bscontroller/monitoring.cpp3
-rw-r--r--ydb/core/mind/bscontroller/virtual_group.cpp152
8 files changed, 130 insertions, 62 deletions
diff --git a/ydb/core/blob_depot/agent/storage_range.cpp b/ydb/core/blob_depot/agent/storage_range.cpp
index 0a4f4e89f4..1c113adf25 100644
--- a/ydb/core/blob_depot/agent/storage_range.cpp
+++ b/ydb/core/blob_depot/agent/storage_range.cpp
@@ -49,12 +49,13 @@ namespace NKikimr::NBlobDepot {
++ResolvesInFlight;
}
- void IssueResolve(TLogoBlobID id) {
+ void IssueResolve(ui64 tag) {
NKikimrBlobDepot::TEvResolve resolve;
auto *item = resolve.AddItems();
- item->SetExactKey(id.AsBinaryString());
+ item->SetExactKey(Reads[tag].AsBinaryString());
item->SetTabletId(Request.TabletId);
item->SetMustRestoreFirst(Request.MustRestoreFirst);
+ item->SetCookie(tag);
Agent.Issue(std::move(resolve), this, nullptr);
++ResolvesInFlight;
@@ -79,14 +80,29 @@ namespace NKikimr::NBlobDepot {
return EndWithError(msg.GetStatus(), msg.GetErrorReason());
}
+#ifndef NDEBUG
+ THashSet<TLogoBlobID> ids;
+#endif
+
for (const auto& key : msg.GetResolvedKeys()) {
const TString& blobId = key.GetKey();
auto id = TLogoBlobID::FromBinary(blobId);
+#ifndef NDEBUG
+ const bool inserted = ids.insert(id).second;
+ Y_VERIFY(inserted);
+#endif
+
if (key.HasErrorReason()) {
return EndWithError(NKikimrProto::ERROR, TStringBuilder() << "failed to resolve blob# " << id
<< ": " << key.GetErrorReason());
} else if (!Request.IsIndexOnly) {
+ const ui64 tag = key.HasCookie() ? key.GetCookie() : Reads.size();
+ if (tag == Reads.size()) {
+ Reads.push_back(id);
+ } else {
+ Y_VERIFY(Reads[tag] == id);
+ }
TReadArg arg{
key.GetValueChain(),
NKikimrBlobStorage::EGetHandleClass::FastRead,
@@ -94,17 +110,14 @@ namespace NKikimr::NBlobDepot {
this,
0,
0,
- Reads.size(),
+ tag,
{}};
- Reads.push_back(id);
++ReadsInFlight;
TString error;
if (!Agent.IssueRead(arg, error)) {
return EndWithError(NKikimrProto::ERROR, TStringBuilder() << "failed to read discovered blob: "
<< error);
}
- } else if (Request.MustRestoreFirst) {
- Y_FAIL("not implemented yet");
} else {
FoundBlobs.try_emplace(id);
}
@@ -128,7 +141,7 @@ namespace NKikimr::NBlobDepot {
}
case NKikimrProto::NODATA:
- IssueResolve(Reads[tag]);
+ IssueResolve(tag);
break;
default:
diff --git a/ydb/core/blob_depot/data_resolve.cpp b/ydb/core/blob_depot/data_resolve.cpp
index c81d1756cb..449fb7cc1d 100644
--- a/ydb/core/blob_depot/data_resolve.cpp
+++ b/ydb/core/blob_depot/data_resolve.cpp
@@ -166,6 +166,8 @@ namespace NKikimr::NBlobDepot {
bool progress = false;
if (!KeysLoaded && !LoadKeys(txc, progress)) {
return progress;
+ } else if (SuccessorTx) {
+ return true;
} else {
KeysLoaded = true;
}
diff --git a/ydb/core/blobstorage/dsproxy/dsproxy.h b/ydb/core/blobstorage/dsproxy/dsproxy.h
index c4bb0d7e39..ab8820c93b 100644
--- a/ydb/core/blobstorage/dsproxy/dsproxy.h
+++ b/ydb/core/blobstorage/dsproxy/dsproxy.h
@@ -516,7 +516,7 @@ private:
protected:
using TThis = TDerived;
- TIntrusivePtr<TBlobStorageGroupInfo> Info;
+ const TIntrusivePtr<TBlobStorageGroupInfo> Info;
TIntrusivePtr<TGroupQueues> GroupQueues;
TIntrusivePtr<TBlobStorageGroupProxyMon> Mon;
TIntrusivePtr<TStoragePoolCounters> PoolCounters;
diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_assimilate.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_assimilate.cpp
index 5b8394ccfb..15138025e5 100644
--- a/ydb/core/blobstorage/dsproxy/dsproxy_assimilate.cpp
+++ b/ydb/core/blobstorage/dsproxy/dsproxy_assimilate.cpp
@@ -314,7 +314,7 @@ public:
const auto& record = ev->Get()->Record;
const TVDiskID vdiskId = VDiskIDFromVDiskID(record.GetVDiskID());
- const ui32 orderNumber = Info->GetOrderNumber(vdiskId);
+ const ui32 orderNumber = Info->GetTopology().GetOrderNumber(vdiskId);
Y_VERIFY(orderNumber < PerVDiskInfo.size());
if (record.GetStatus() == NKikimrProto::OK) {
diff --git a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp
index e663567105..6a8fa70cc4 100644
--- a/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp
+++ b/ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp
@@ -816,7 +816,7 @@ TVDiskID TBlobStorageGroupInfo::GetVDiskInSubgroup(ui32 idxInSubgroup, ui32 hash
ui32 TBlobStorageGroupInfo::GetOrderNumber(const TVDiskID &vdisk) const {
Y_VERIFY_S(vdisk.GroupID == GroupID, "Expected GroupID# " << GroupID << ", given GroupID# " << vdisk.GroupID);
- Y_VERIFY_S(vdisk.GroupGeneration == GroupGeneration, "Expected GroupGeeration# " << GroupGeneration
+ Y_VERIFY_S(vdisk.GroupGeneration == GroupGeneration, "Expected GroupGeneration# " << GroupGeneration
<< ", given GroupGeneration# " << vdisk.GroupGeneration);
return Topology->GetOrderNumber(vdisk);
}
diff --git a/ydb/core/mind/bscontroller/impl.h b/ydb/core/mind/bscontroller/impl.h
index ce9bf37bb1..65ca1b30a8 100644
--- a/ydb/core/mind/bscontroller/impl.h
+++ b/ydb/core/mind/bscontroller/impl.h
@@ -508,7 +508,6 @@ public:
TMaybe<Table::ErrorReason::Type> ErrorReason;
TMaybe<Table::NeedAlter::Type> NeedAlter;
std::optional<NKikimrBlobStorage::TGroupMetrics> GroupMetrics;
- bool CommitInProgress = false;
bool Down = false; // is group are down right now (not selectable)
TVector<TIndirectReferable<TVSlotInfo>::TPtr> VDisksInGroup;
@@ -1646,6 +1645,7 @@ private:
void RenderFooter(IOutputStream& out);
void RenderMonPage(IOutputStream& out);
void RenderInternalTables(IOutputStream& out, const TString& table);
+ void RenderVirtualGroups(IOutputStream& out);
void RenderGroupDetail(IOutputStream &out, TGroupId groupId);
void RenderGroupsInStoragePool(IOutputStream &out, const TBoxStoragePoolId& id);
void RenderVSlotTable(IOutputStream& out, std::function<void()> callback);
diff --git a/ydb/core/mind/bscontroller/monitoring.cpp b/ydb/core/mind/bscontroller/monitoring.cpp
index 60645b190a..5f1bf21ebc 100644
--- a/ydb/core/mind/bscontroller/monitoring.cpp
+++ b/ydb/core/mind/bscontroller/monitoring.cpp
@@ -909,6 +909,8 @@ bool TBlobStorageController::OnRenderAppHtmlPage(NMon::TEvRemoteHttpInfo::TPtr e
} else if (page == "InternalTables") {
const TString table = cgi.Has("table") ? cgi.Get("table") : "pdisks";
RenderInternalTables(str, table);
+ } else if (page == "VirtualGroups") {
+ RenderVirtualGroups(str);
} else if (page == "StopGivingGroups") {
StopGivingGroups = true;
str << "OK";
@@ -960,6 +962,7 @@ void TBlobStorageController::RenderMonPage(IOutputStream& out) {
(SelfHealEnable ? "enabled" : "disabled") << ")<br>";
out << "<a href='app?TabletID=" << TabletID() << "&page=HealthEvents'>Health events</a><br>";
out << "<a href='app?TabletID=" << TabletID() << "&page=Scrub'>Scrub state</a><br>";
+ out << "<a href='app?TabletID=" << TabletID() << "&page=VirtualGroups'>Virtual groups</a><br>";
out << "<a href='app?TabletID=" << TabletID() << "&page=InternalTables'>Internal tables</a><br>";
HTML(out) {
diff --git a/ydb/core/mind/bscontroller/virtual_group.cpp b/ydb/core/mind/bscontroller/virtual_group.cpp
index 66359ee855..a8abe9645f 100644
--- a/ydb/core/mind/bscontroller/virtual_group.cpp
+++ b/ydb/core/mind/bscontroller/virtual_group.cpp
@@ -185,64 +185,37 @@ namespace NKikimr::NBsController {
class TTxUpdateGroup : public TTransactionBase<TBlobStorageController> {
TVirtualGroupSetupMachine *Machine;
std::optional<TConfigState> State;
+ std::function<void(TGroupInfo&)> Callback;
public:
- TTxUpdateGroup(TVirtualGroupSetupMachine *machine)
+ TTxUpdateGroup(TVirtualGroupSetupMachine *machine, std::function<void(TGroupInfo&)>&& callback)
: TTransactionBase(machine->Self)
, Machine(machine)
+ , Callback(std::move(callback))
{}
bool Execute(TTransactionContext& txc, const TActorContext&) override {
- TGroupInfo *group = GetGroup(true);
- NIceDb::TNiceDb db(txc.DB);
- using T = Schema::Group;
- auto row = db.Table<T>().Key(group->ID);
-#define PARAM(NAME) \
- if (const auto& cell = group->NAME) { \
- row.Update<T::NAME>(*cell); \
- }
- PARAM(VirtualGroupState)
- PARAM(BlobDepotConfig)
- PARAM(BlobDepotId)
- PARAM(ErrorReason)
- PARAM(NeedAlter)
-#undef PARAM
- if (group->SeenOperational) {
- row.Update<T::SeenOperational>(true);
- }
- if (group->VirtualGroupState == NKikimrBlobStorage::EVirtualGroupState::WORKING &&
- group->DecommitStatus == NKikimrBlobStorage::TGroupDecommitStatus::PENDING) {
- State.emplace(*Self, Self->HostRecords, TActivationContext::Now());
- TGroupInfo *group = State->Groups.FindForUpdate(Machine->GroupId);
- Y_VERIFY(group);
- group->DecommitStatus = NKikimrBlobStorage::TGroupDecommitStatus::IN_PROGRESS;
- group->ContentChanged = true;
- TString error;
- if (State->Changed() && !Self->CommitConfigUpdates(*State, false, false, false, txc, &error)) {
- STLOG(PRI_ERROR, BS_CONTROLLER, BSCVG08, "failed to commit update",
- (VirtualGroupId, Machine->GroupId), (Error, error));
- State->Rollback();
- State.reset();
- }
+ State.emplace(*Self, Self->HostRecords, TActivationContext::Now());
+ TGroupInfo *group = State->Groups.FindForUpdate(Machine->GroupId);
+ Y_VERIFY(group);
+ Callback(*group);
+ TString error;
+ if (State->Changed() && !Self->CommitConfigUpdates(*State, false, false, false, txc, &error)) {
+ STLOG(PRI_ERROR, BS_CONTROLLER, BSCVG08, "failed to commit update",
+ (VirtualGroupId, Machine->GroupId), (Error, error));
+ State->Rollback();
+ State.reset();
}
return true;
}
void Complete(const TActorContext&) override {
- TGroupInfo *group = GetGroup(false);
+ TGroupInfo *group = Machine->GetGroup();
Y_VERIFY(group->VirtualGroupSetupMachineId == Machine->SelfId());
- TActivationContext::Send(new IEventHandle(TEvents::TSystem::Bootstrap, 0, Machine->SelfId(), {}, nullptr, 0));
if (State) {
State->ApplyConfigUpdates();
}
- }
-
- private:
- TGroupInfo *GetGroup(bool commitInProgress) {
- TGroupInfo *group = Machine->GetGroup();
- Y_VERIFY(group->CommitInProgress != commitInProgress);
- group->CommitInProgress = commitInProgress;
- return group;
+ TActivationContext::Send(new IEventHandle(TEvents::TSystem::Bootstrap, 0, Machine->SelfId(), {}, nullptr, 0));
}
};
@@ -382,15 +355,17 @@ namespace NKikimr::NBsController {
STLOG(PRI_INFO, BS_CONTROLLER, BSCVG04, "received TEvCreateTabletReply", (TabletId, Self->TabletID()),
(Msg, ev->Get()->Record));
- TGroupInfo *group = GetGroup();
auto& record = ev->Get()->Record;
if (record.GetStatus() == NKikimrProto::OK || record.GetStatus() == NKikimrProto::ALREADY) {
BlobDepotTabletId = record.GetTabletID();
Y_VERIFY(BlobDepotTabletId);
} else {
- group->VirtualGroupState = NKikimrBlobStorage::EVirtualGroupState::CREATE_FAILED;
- group->ErrorReason = SingleLineProto(record);
- Self->Execute(new TTxUpdateGroup(this));
+ Self->Execute(new TTxUpdateGroup(this, [&](TGroupInfo& group) {
+ group.VirtualGroupState = NKikimrBlobStorage::EVirtualGroupState::CREATE_FAILED;
+ group.ErrorReason = TStringBuilder() << "failed to create BlobDepot tablet"
+ << " Reason# " << NKikimrHive::EErrorReason_Name(record.GetErrorReason())
+ << " Status# " << NKikimrProto::EReplyStatus_Name(record.GetStatus());
+ }));
}
NTabletPipe::CloseAndForgetClient(SelfId(), HivePipeId);
@@ -416,12 +391,17 @@ namespace NKikimr::NBsController {
}
void Handle(TEvBlobDepot::TEvApplyConfigResult::TPtr /*ev*/) {
- TGroupInfo *group = GetGroup();
- group->VirtualGroupState = NKikimrBlobStorage::EVirtualGroupState::WORKING;
- group->BlobDepotId = BlobDepotTabletId;
- group->NeedAlter = false; // race-check
- Self->Execute(new TTxUpdateGroup(this));
NTabletPipe::CloseAndForgetClient(SelfId(), BlobDepotPipeId);
+
+ Self->Execute(new TTxUpdateGroup(this, [&](TGroupInfo& group) {
+ group.VirtualGroupState = NKikimrBlobStorage::EVirtualGroupState::WORKING;
+ group.BlobDepotId = BlobDepotTabletId;
+ group.NeedAlter = false;
+ if (group.DecommitStatus == NKikimrBlobStorage::TGroupDecommitStatus::PENDING) {
+ group.DecommitStatus = NKikimrBlobStorage::TGroupDecommitStatus::IN_PROGRESS;
+ group.ContentChanged = true;
+ }
+ }));
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -566,4 +546,74 @@ namespace NKikimr::NBsController {
Execute(new TTxDecommitGroup(this, ev));
}
+ void TBlobStorageController::RenderVirtualGroups(IOutputStream& out) {
+ HTML(out) {
+ DIV_CLASS("panel panel-info") {
+ DIV_CLASS("panel-heading") {
+ out << "Virtual groups";
+ }
+ DIV_CLASS("panel-body") {
+ TABLE_CLASS("table table-condensed") {
+ TABLEHEAD() {
+ TABLER() {
+ TABLEH() { out << "GroupId"; }
+ TABLEH() { out << "StoragePoolName"; }
+ TABLEH() { out << "Name"; }
+ TABLEH() { out << "State"; }
+ TABLEH() { out << "HiveId"; }
+ TABLEH() { out << "ErrorReason"; }
+ TABLEH() { out << "DecommitStatus"; }
+ }
+ }
+ TABLEBODY() {
+ for (const auto& [groupId, group] : GroupMap) {
+ if (!group->VirtualGroupState) {
+ continue;
+ }
+
+ TABLER() {
+ TABLED() {
+ out << groupId;
+ }
+ TABLED() {
+ const auto it = StoragePools.find(group->StoragePoolId);
+ Y_VERIFY(it != StoragePools.end());
+ out << it->second.Name;
+ }
+ TABLED() {
+ if (group->VirtualGroupName) {
+ out << *group->VirtualGroupName;
+ } else {
+ out << "<i>null</i>";
+ }
+ }
+ TABLED() {
+ out << NKikimrBlobStorage::EVirtualGroupState_Name(*group->VirtualGroupState);
+ }
+ TABLED() {
+ if (group->HiveId) {
+ out << *group->HiveId;
+ } else {
+ out << "<i>null</i>";
+ }
+ }
+ TABLED() {
+ if (group->ErrorReason) {
+ out << *group->ErrorReason;
+ } else {
+ out << "<i>null</i>";
+ }
+ }
+ TABLED() {
+ out << NKikimrBlobStorage::TGroupDecommitStatus::E_Name(group->DecommitStatus);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
} // NKikimr::NBsController