Skip to content

Commit

Permalink
Merge 817e2ef into 346aedc
Browse files Browse the repository at this point in the history
  • Loading branch information
swalrus1 authored Nov 25, 2024
2 parents 346aedc + 817e2ef commit 430d20c
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 17 deletions.
1 change: 1 addition & 0 deletions ydb/core/protos/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1685,6 +1685,7 @@ message TColumnShardConfig {
message TRepairInfo {
optional string ClassName = 1;
optional string Description = 2;
optional bool DryRun = 3;
}
repeated TRepairInfo Repairs = 15;

Expand Down
22 changes: 16 additions & 6 deletions ydb/core/tx/columnshard/columnshard__init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class TTxApplyNormalizer: public TTransactionBase<TColumnShard> {
public:
TTxApplyNormalizer(TColumnShard* self, NOlap::INormalizerChanges::TPtr changes)
: TBase(self)
, IsDryRun(self->NormalizerController.GetNormalizer()->GetIsDryRun())
, Changes(changes) {
}

Expand All @@ -187,16 +188,20 @@ class TTxApplyNormalizer: public TTransactionBase<TColumnShard> {
}

private:
const bool IsDryRun;
bool NormalizerFinished = false;
NOlap::INormalizerChanges::TPtr Changes;
};

bool TTxApplyNormalizer::Execute(TTransactionContext& txc, const TActorContext&) {
NActors::TLogContextGuard gLogging =
NActors::TLogContextBuilder::Build(NKikimrServices::TX_COLUMNSHARD)("tablet_id", Self->TabletID())("event", "TTxApplyNormalizer::Execute");
AFL_INFO(NKikimrServices::TX_COLUMNSHARD)("step", "TTxApplyNormalizer.Execute")("details", Self->NormalizerController.DebugString());
if (!Changes->ApplyOnExecute(txc, Self->NormalizerController)) {
return false;
AFL_INFO(NKikimrServices::TX_COLUMNSHARD)("step", "TTxApplyNormalizer.Execute")("details", Self->NormalizerController.DebugString())(
"dry_run", IsDryRun);
if (!IsDryRun) {
if (!Changes->ApplyOnExecute(txc, Self->NormalizerController)) {
return false;
}
}

if (Self->NormalizerController.GetNormalizer()->DecActiveCounters() == 0) {
Expand All @@ -211,9 +216,14 @@ void TTxApplyNormalizer::Complete(const TActorContext& ctx) {
NActors::TLogContextGuard gLogging = NActors::TLogContextBuilder::Build(NKikimrServices::TX_COLUMNSHARD)("tablet_id", Self->TabletID())(
"event", "TTxApplyNormalizer::Complete");
AFL_VERIFY(!Self->NormalizerController.IsNormalizationFinished())("details", Self->NormalizerController.DebugString());
AFL_WARN(NKikimrServices::TX_COLUMNSHARD)("event", "apply_normalizer_changes")(
"details", Self->NormalizerController.DebugString())("size", Changes->GetSize());
Changes->ApplyOnComplete(Self->NormalizerController);
AFL_WARN(NKikimrServices::TX_COLUMNSHARD)("event", "apply_normalizer_changes")("details", Self->NormalizerController.DebugString())(
"size", Changes->GetSize())("dry_run", IsDryRun);
if (IsDryRun) {
AFL_WARN(NKikimrServices::TX_COLUMNSHARD)("event", "normalizer_changes_dry_run")(
"normalizer", Self->NormalizerController.GetNormalizer()->GetClassName())("changes", Changes->DebugString());
} else {
Changes->ApplyOnComplete(Self->NormalizerController);
}
if (!NormalizerFinished) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tx/columnshard/normalizer/abstract/abstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void TNormalizationController::InitNormalizers(const TInitContext& ctx) {
auto component = INormalizerComponent::TFactory::MakeHolder(i.GetClassName(), ctx);
AFL_VERIFY(component)("class_name", i.GetClassName());
auto normalizer = RegisterNormalizer(std::shared_ptr<INormalizerComponent>(component.Release()));
normalizer->SetIsRepair(true).SetUniqueDescription(i.GetDescription());
normalizer->SetIsRepair(true).SetIsDryRun(i.GetDryRun()).SetUniqueDescription(i.GetDescription());
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions ydb/core/tx/columnshard/normalizer/abstract/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ class INormalizerChanges {
}

virtual ui64 GetSize() const = 0;
virtual TString DebugString() const {
return TStringBuilder() << "size=" << GetSize();
}
};

class TTrivialNormalizerTask: public INormalizerTask {
Expand Down Expand Up @@ -170,6 +173,7 @@ class TNormalizationController {
class INormalizerComponent {
private:
YDB_ACCESSOR(bool, IsRepair, false);
YDB_ACCESSOR(bool, IsDryRun, false);
YDB_ACCESSOR_DEF(TString, UniqueDescription);
YDB_ACCESSOR(TString, UniqueId, TGUID::CreateTimebased().AsUuidString());

Expand Down
26 changes: 16 additions & 10 deletions ydb/core/tx/columnshard/normalizer/portion/broken_blobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <ydb/core/tx/columnshard/engines/scheme/filtered_scheme.h>
#include <ydb/core/tx/columnshard/tables_manager.h>

#include <util/string/vector.h>

namespace NKikimr::NOlap::NNormalizer::NBrokenBlobs {

class TNormalizerResult: public INormalizerChanges {
Expand All @@ -33,17 +35,8 @@ class TNormalizerResult: public INormalizerChanges {
copy.SaveMetaToDatabase(db);
}
if (BrokenPortions.size()) {
TStringBuilder sb;
ui64 recordsCount = 0;
sb << "path_ids:[";
for (auto&& [_, p] : BrokenPortions) {
sb << p.GetPortionInfo().GetPathId() << ",";
recordsCount += p.GetPortionInfo().GetRecordsCount();
}
sb << "];";
sb << "records_count:" << recordsCount;
NIceDb::TNiceDb db(txc.DB);
normController.AddNormalizerEvent(db, "REMOVE_PORTIONS", sb);
normController.AddNormalizerEvent(db, "REMOVE_PORTIONS", DebugString());
}
return true;
}
Expand All @@ -54,6 +47,19 @@ class TNormalizerResult: public INormalizerChanges {
ui64 GetSize() const override {
return BrokenPortions.size();
}

TString DebugString() const override {
TStringBuilder sb;
ui64 recordsCount = 0;
sb << "path_ids=[";
for (auto&& [_, p] : BrokenPortions) {
sb << p.GetPortionInfo().GetPathId() << ",";
recordsCount += p.GetPortionInfo().GetRecordsCount();
}
sb << "]";
sb << ";records_count=" << recordsCount;
return sb;
}
};

class TReadTask: public NOlap::NBlobOperations::NRead::ITask {
Expand Down
9 changes: 9 additions & 0 deletions ydb/core/tx/columnshard/normalizer/portion/leaked_blobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include <ydb/library/actors/core/actor.h>

#include <util/string/vector.h>

namespace NKikimr::NOlap {

class TLeakedBlobsNormalizerChanges: public INormalizerChanges {
Expand Down Expand Up @@ -42,6 +44,13 @@ class TLeakedBlobsNormalizerChanges: public INormalizerChanges {
ui64 GetSize() const override {
return Leaks.size();
}

TString DebugString() const override {
TStringBuilder sb;
sb << "tablet=" << TabletId;
sb << ";leaked_blobs=[" << JoinStrings(Leaks.begin(), Leaks.end(), ",") << "]";
return sb;
}
};

class TRemoveLeakedBlobsActor: public TActorBootstrapped<TRemoveLeakedBlobsActor> {
Expand Down

0 comments on commit 430d20c

Please sign in to comment.