Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmorozov333 committed Jul 6, 2024
1 parent 0fd7910 commit 67e208d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 25 deletions.
10 changes: 7 additions & 3 deletions ydb/core/tx/columnshard/blobs_action/abstract/blob_set.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include <ydb/core/tx/columnshard/common/tablet_id.h>
#include <ydb/core/tx/columnshard/blob.h>
#include <ydb/core/util/gen_step.h>

#include <ydb/library/accessor/accessor.h>
#include <ydb/library/services/services.pb.h>
Expand Down Expand Up @@ -47,7 +48,7 @@ class TTabletByBlob {
class TBlobsByGenStep {
private:
struct Comparator {
bool operator<(const TLogoBlobID& l, const TLogoBlobID& r) const {
bool operator()(const TLogoBlobID& l, const TLogoBlobID& r) const {
TGenStep gsl(l);
TGenStep gsr(l);
if (gsl == gsr) {
Expand All @@ -65,6 +66,9 @@ class TBlobsByGenStep {
[[nodiscard]] bool Remove(const TLogoBlobID& blobId) {
return Blobs.erase(blobId);
}
bool IsEmpty() const {
return Blobs.empty();
}
ui32 GetSize() const {
return Blobs.size();
}
Expand All @@ -75,11 +79,11 @@ class TBlobsByGenStep {
}

template <class TActor>
bool ExtractFront(const TGenStep border, const ui32 countLimit, const TActor& actor) {
bool ExtractTo(const TGenStep includeBorder, const ui32 countLimit, const TActor& actor) {
ui32 idx = 0;
for (auto it = Blobs.begin(); it != Blobs.end(); ++it) {
TGenStep gs(*it);
if (border < gs) {
if (includeBorder < gs) {
return true;
}
if (++idx > countLimit) {
Expand Down
28 changes: 22 additions & 6 deletions ydb/core/tx/columnshard/blobs_action/bs/blob_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ void TBlobBatch::SendWriteBlobRequest(const TString& blobData, const TUnifiedBlo
}

void TBlobBatch::OnBlobWriteResult(const TLogoBlobID& blobId, const NKikimrProto::EReplyStatus status) {
BatchInfo->Counters.OnPutResult(blobId.BlobSize());
Y_ABORT_UNLESS(status == NKikimrProto::OK, "The caller must handle unsuccessful status");
Y_ABORT_UNLESS(BatchInfo);
Y_ABORT_UNLESS(blobId.Cookie() < BatchInfo->InFlight.size());
Expand Down Expand Up @@ -204,6 +203,22 @@ class TBlobManager::TGCContext {
YDB_ACCESSOR_DEF(std::deque<TUnifiedBlobId>, KeepsToErase);
YDB_READONLY_DEF(std::shared_ptr<NDataSharing::TStorageSharedBlobsManager>, SharedBlobsManager);
public:
ui64 GetKeepBytes() const {
ui64 size = 0;
for (auto&& i : KeepsToErase) {
size += i.BlobSize();
}
return size;
}

ui64 GetDeleteBytes() const {
ui64 size = 0;
for (TTabletsByBlob::TIterator it(ExtractedToRemoveFromDB); it.IsValid(); ++it) {
size += it.GetBlobId().BlobSize();
}
return size;
}

TGCContext(const std::shared_ptr<NDataSharing::TStorageSharedBlobsManager>& sharedBlobsManager)
: SharedBlobsManager(sharedBlobsManager)
{
Expand Down Expand Up @@ -270,11 +285,11 @@ bool TBlobManager::DrainKeepTo(const TGenStep& dest, TGCContext& gcContext) {
if (BlobsToDelete.ExtractBlobTo(keepUnified, gcContext.MutableExtractedToRemoveFromDB())) {
if (logoBlobId.Generation() == CurrentGen) {
AFL_INFO(NKikimrServices::TX_COLUMNSHARD_BLOBS_BS)("to_not_keep", keepUnified.ToStringNew());
continue;
return;
}
if (gcContext.GetSharedBlobsManager()->BuildStoreCategories({ keepUnified }).GetDirect().IsEmpty()) {
AFL_INFO(NKikimrServices::TX_COLUMNSHARD_BLOBS_BS)("to_not_keep_not_direct", keepUnified.ToStringNew());
continue;
return;
}
AFL_INFO(NKikimrServices::TX_COLUMNSHARD_BLOBS_BS)("to_not_keep_old", keepUnified.ToStringNew());
gcContext.MutablePerGroupGCListsInFlight()[bAddress].DontKeepList.insert(logoBlobId);
Expand All @@ -284,7 +299,7 @@ bool TBlobManager::DrainKeepTo(const TGenStep& dest, TGCContext& gcContext) {
}
};

return BlobsToKeep.ExtractFront(dest, gcContext.GetFreeSpace(), pred);
return BlobsToKeep.ExtractTo(dest, gcContext.GetFreeSpace(), pred);
}

std::shared_ptr<NBlobOperations::NBlobStorage::TGCTask> TBlobManager::BuildGCTask(const TString& storageId,
Expand Down Expand Up @@ -345,12 +360,13 @@ std::shared_ptr<NBlobOperations::NBlobStorage::TGCTask> TBlobManager::BuildGCTas
PreviousGCTime = TInstant::Zero();
}

BlobsManagerCounters.OnGCTask(gcContext.GetKeepsToErase().size(), gcContext.GetExtractedToRemoveFromDB().GetSize(), gcContext.IsFull(), !!CollectGenStepInFlight);
BlobsManagerCounters.GCCounters.OnGCTask(gcContext.GetKeepsToErase().size(), gcContext.GetKeepBytes(),
gcContext.GetExtractedToRemoveFromDB().GetSize(), gcContext.GetDeleteBytes(), gcContext.IsFull(), !!CollectGenStepInFlight);
auto removeCategories = sharedBlobsInfo->BuildRemoveCategories(std::move(gcContext.MutableExtractedToRemoveFromDB()));
auto result = std::make_shared<NBlobOperations::NBlobStorage::TGCTask>(storageId, std::move(gcContext.MutablePerGroupGCListsInFlight()),
CollectGenStepInFlight, std::move(gcContext.MutableKeepsToErase()), manager, std::move(removeCategories), counters, TabletInfo->TabletID, CurrentGen);
if (result->IsEmpty()) {
BlobsManagerCounters.OnEmptyGCTask();
BlobsManagerCounters.GCCounters.OnEmptyGCTask();
CollectGenStepInFlight = {};
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tx/columnshard/blobs_action/bs/blob_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class TBlobManager : public IBlobManager, public TCommonBlobsTracker {
virtual void DoSaveBlobBatchOnExecute(const TBlobBatch& blobBatch, IBlobManagerDb& db) override;
virtual void DoSaveBlobBatchOnComplete(TBlobBatch&& blobBatch) override;
void DrainDeleteTo(const TGenStep& dest, TGCContext& gcContext);
[[nodiscard]] bool DrainKeepTo(const TGenStep& dest, TGCContext& gcContext, const bool controlCapacity = true);
[[nodiscard]] bool DrainKeepTo(const TGenStep& dest, TGCContext& gcContext);
public:
TBlobManager(TIntrusivePtr<TTabletStorageInfo> tabletInfo, const ui32 gen, const TTabletId selfTabletId);

Expand Down
18 changes: 9 additions & 9 deletions ydb/core/tx/columnshard/counters/blobs_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ namespace NKikimr::NColumnShard {

TBlobsManagerCounters::TBlobsManagerCounters(const TString& module)
: TCommonCountersOwner(module)
, GCCounters(*this, "GC")
, CurrentGen(TBase::GetValue("CurrentGen"))
, CurrentStep(TBase::GetValue("CurrentStep"))
, BlobsToKeepCount(TBase::GetValue("BlobsToKeep/Count"))
, BlobsToDeleteCount(TBase::GetValue("BlobsToDelete/Count"))
, BlobsToDeleteDelayedCount(TBase::GetValue("BlobsToDeleteDelayed/Count"))
, BlobsToKeepCount(TBase::GetValue("BlobsToKeep/Count"))
, CurrentGen(TBase::GetValue("CurrentGen"))
, CurrentStep(TBase::GetValue("CurrentStep"))
, GCCounters(*this, "GC")

{

}

TBlobsManagerGCCounters::TBlobsManagerGCCounters(const TCommonCountersOwner& sameAs, const TString& componentName)
: TBase(saveAs, componentName)
: TBase(sameAs, componentName)
, SkipCollectionEmpty(TBase::GetDeriviative("Skip/Empty/Count"))
, SkipCollectionThrottling(TBase::GetDeriviative("Skip/Throttling/Count"))
{
Expand All @@ -42,11 +42,11 @@ void TBlobsManagerGCCounters::OnGCTask(const ui32 keepsCount, const ui32 keepByt
FullGCTasks->Add(1);
}
KeepsCountTasks->Collect(keepsCount);
KeepsCountBlobs->Collect(keepsCount, keepsCount);
KeepsCountBytes->Collect(keepsCount, keepsBytes);
KeepsCountBlobs->Collect((i64)keepsCount, keepsCount);
KeepsCountBytes->Collect((i64)keepsCount, keepBytes);
DeletesCountTasks->Collect(deleteCount);
DeletesCountBlobs->Collect(deleteCount, deleteCount);
DeletesCountBytes->Collect(keepsCount, deleteBytes);
DeletesCountBlobs->Collect((i64)deleteCount, deleteCount);
DeletesCountBytes->Collect((i64)deleteCount, deleteBytes);
if (moveBarrier) {
MoveBarriers->Add(1);
} else {
Expand Down
14 changes: 8 additions & 6 deletions ydb/core/tx/columnshard/counters/blobs_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "common/owner.h"

#include <ydb/core/base/logoblob.h>
#include <ydb/core/tx/columnshard/blobs_action/abstract/blob_set.h>
#include <ydb/core/tx/columnshard/blobs_action/abstract/common.h>

#include <library/cpp/monlib/dynamic_counters/counters.h>
Expand All @@ -15,6 +16,7 @@ namespace NKikimr::NColumnShard {

class TBlobsManagerGCCounters: public TCommonCountersOwner {
private:
using TBase = TCommonCountersOwner;
NMonitoring::THistogramPtr KeepsCountBytes;
NMonitoring::THistogramPtr KeepsCountBlobs;
NMonitoring::THistogramPtr KeepsCountTasks;
Expand All @@ -32,13 +34,13 @@ class TBlobsManagerGCCounters: public TCommonCountersOwner {

TBlobsManagerGCCounters(const TCommonCountersOwner& sameAs, const TString& componentName);

void OnGCTask(const ui32 keepsCount, const ui32 keepBytes, const ui32 deleteCount, const ui32 deleteBytes,
void OnGCTask(const ui32 keepsCount, const ui32 keepBytes, const ui32 deleteCount, const ui32 deleteBytes,
const bool isFull, const bool moveBarrier) const;

void OnEmptyGCTask() const {
EmptyGCTasks->Add(1);
}
}
};

class TBlobsManagerCounters: public TCommonCountersOwner {
private:
Expand All @@ -51,13 +53,13 @@ class TBlobsManagerCounters: public TCommonCountersOwner {
const NMonitoring::TDynamicCounters::TCounterPtr CurrentStep;
const TBlobsManagerGCCounters GCCounters;
TBlobsManagerCounters(const TString& module);
void OnBlobsToDelete(const TTabletsByBlob& blobs) const {
void OnBlobsToDelete(const NOlap::TTabletsByBlob& blobs) const {
BlobsToDeleteCount->Set(blobs.GetSize());
}
void OnBlobsToKeep(const TBlobsByGenStep& blobs) const {
BlobsToKeepCount->Set(blobs.GetBlobsCount());
void OnBlobsToKeep(const NOlap::TBlobsByGenStep& blobs) const {
BlobsToKeepCount->Set(blobs.GetSize());
}
void OnBlobsToDeleteDelayed(const TTabletsByBlob& blobs) const {
void OnBlobsToDeleteDelayed(const NOlap::TTabletsByBlob& blobs) const {
BlobsToDeleteDelayedCount->Set(blobs.GetSize());
}
};
Expand Down

0 comments on commit 67e208d

Please sign in to comment.