Skip to content

KIKIMR-20521: Add UseVDisksBalancing feature flag #523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ydb/core/base/blobstorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ struct TEvBlobStorage {
EvWriteMetadata,
EvPermitGarbageCollection,
EvReplInvoke,
EvStartBalancing,

EvYardInitResult = EvPut + 9 * 512, /// 268 636 672
EvLogResult,
Expand Down
1 change: 1 addition & 0 deletions ydb/core/blobstorage/nodewarden/node_warden_vdisk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ namespace NKikimr::NStorage {
vdiskConfig->EnableVDiskCooldownTimeout = Cfg->EnableVDiskCooldownTimeout;
vdiskConfig->ReplPausedAtStart = Cfg->VDiskReplPausedAtStart;
vdiskConfig->EnableVPatch = EnableVPatch;
vdiskConfig->FeatureFlags = Cfg->FeatureFlags;

// issue initial report to whiteboard before creating actor to avoid races
Send(WhiteboardId, new NNodeWhiteboard::TEvWhiteboard::TEvVDiskStateUpdate(vdiskId, groupInfo->GetStoragePoolName(),
Expand Down
29 changes: 29 additions & 0 deletions ydb/core/blobstorage/vdisk/balance/balancing_actor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "balancing_actor.h"
#include "defs.h"


namespace NKikimr {

class TBalancingActor : public TActorBootstrapped<TBalancingActor> {
private:
std::shared_ptr<TBalancingCtx> Ctx;
public:
void Bootstrap() {
Become(&TThis::StateFunc);
}

STRICT_STFUNC(StateFunc,
CFunc(NActors::TEvents::TEvPoison::EventType, Die)
);

TBalancingActor(std::shared_ptr<TBalancingCtx> &ctx)
: TActorBootstrapped<TBalancingActor>()
, Ctx(ctx)
{
}
};

IActor* CreateBalancingActor(std::shared_ptr<TBalancingCtx> ctx) {
return new TBalancingActor(ctx);
}
}
8 changes: 8 additions & 0 deletions ydb/core/blobstorage/vdisk/balance/balancing_actor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include "defs.h"


namespace NKikimr {
IActor* CreateBalancingActor(std::shared_ptr<TBalancingCtx> ctx);
} // NKikimr
41 changes: 41 additions & 0 deletions ydb/core/blobstorage/vdisk/balance/defs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#pragma once

#include <ydb/core/blobstorage/vdisk/common/vdisk_context.h>
#include <ydb/core/blobstorage/vdisk/common/vdisk_pdiskctx.h>
#include <ydb/core/blobstorage/vdisk/hulldb/hull_ds_all_snap.h>
#include <ydb/core/blobstorage/vdisk/common/vdisk_hulllogctx.h>


namespace NKikimr {
struct TBalancingCtx {
TIntrusivePtr<TVDiskContext> VCtx;
TPDiskCtxPtr PDiskCtx;
TActorId SkeletonId;
NMonGroup::TBalancingGroup MonGroup;

NKikimr::THullDsSnap Snap;

TIntrusivePtr<TVDiskConfig> VDiskCfg;
TIntrusivePtr<TBlobStorageGroupInfo> GInfo;

TBalancingCtx(
TIntrusivePtr<TVDiskContext> vCtx,
TPDiskCtxPtr pDiskCtx,
TActorId skeletonId,
NKikimr::THullDsSnap snap,
TIntrusivePtr<TVDiskConfig> vDiskCfg,
TIntrusivePtr<TBlobStorageGroupInfo> gInfo
)
: VCtx(std::move(vCtx))
, PDiskCtx(std::move(pDiskCtx))
, SkeletonId(skeletonId)
, MonGroup(VCtx->VDiskCounters, "subsystem", "balancing")
, Snap(std::move(snap))
, VDiskCfg(std::move(vDiskCfg))
, GInfo(std::move(gInfo))
{
}
};

struct TEvStartBalancing : TEventLocal<TEvStartBalancing, TEvBlobStorage::EvStartBalancing> {};
} // NKikimr
20 changes: 20 additions & 0 deletions ydb/core/blobstorage/vdisk/balance/ya.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
LIBRARY()

PEERDIR(
ydb/core/blobstorage/base
ydb/core/blobstorage/groupinfo
ydb/core/blobstorage/vdisk/common
ydb/core/blobstorage/vdisk/hulldb
ydb/core/blobstorage/vdisk/ingress
ydb/core/blobstorage/vdisk/repl
)

SRCS(
balancing_actor.cpp
)

END()

RECURSE_FOR_TESTS(
ut
)
3 changes: 3 additions & 0 deletions ydb/core/blobstorage/vdisk/common/vdisk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ namespace NKikimr {
bool EnableVDiskCooldownTimeout;
TControlWrapper EnableVPatch = true;

///////////// FEATURE FLAGS ////////////////////////
NKikimrConfig::TFeatureFlags FeatureFlags;

TVDiskConfig(const TBaseInfo &baseInfo);
void Merge(const NKikimrBlobStorage::TVDiskConfig &update);
private:
Expand Down
10 changes: 10 additions & 0 deletions ydb/core/blobstorage/vdisk/common/vdisk_mongroups.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,16 @@ public:
COUNTER_DEF(DefragBytesRewritten);
};

///////////////////////////////////////////////////////////////////////////////////
// TBalancingGroup
///////////////////////////////////////////////////////////////////////////////////
class TBalancingGroup : public TBase {
public:
GROUP_CONSTRUCTOR(TBalancingGroup)
{
}
};

} // NMonGroup
} // NKikimr

18 changes: 18 additions & 0 deletions ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <ydb/core/base/feature_flags.h>
#include <ydb/core/blobstorage/groupinfo/blobstorage_groupinfo_iter.h>
#include <ydb/core/blobstorage/vdisk/localrecovery/localrecovery_public.h>
#include <ydb/core/blobstorage/vdisk/balance/balancing_actor.h>
#include <ydb/core/blobstorage/vdisk/hullop/blobstorage_hull.h>
#include <ydb/core/blobstorage/vdisk/hullop/blobstorage_hulllog.h>
#include <ydb/core/blobstorage/vdisk/huge/blobstorage_hullhuge.h>
Expand Down Expand Up @@ -1711,6 +1712,7 @@ namespace NKikimr {
ReplDone = true;
}
UpdateReplState();
RunBalancing(ctx);
}

void SkeletonErrorState(const TActorContext &ctx,
Expand Down Expand Up @@ -2449,6 +2451,20 @@ namespace NKikimr {
ev->Get()->Callback({}, "replication is not in progress");
}

void RunBalancing(const TActorContext &ctx) {
if (!Config->FeatureFlags.GetUseVDisksBalancing()) {
return;
}
if (BalancingId) {
ActiveActors.Erase(BalancingId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А тут не надо отправить PoisonPill балансеру?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кажется действительно нужно, я до этого видимо не внимательно прочитал код и думал что он сам пошлет PoisonPill при Erase, а он шлет только в деструкторе тем что остались внем.
Замержу сейчас так, а в следующем пр поправлю

}
auto balancingCtx = std::make_shared<TBalancingCtx>(
VCtx, PDiskCtx, SelfId(), Hull->GetHullDs()->GetIndexSnapshot(), Config, GInfo
);
BalancingId = ctx.Register(CreateBalancingActor(balancingCtx));
ActiveActors.Insert(BalancingId, __FILE__, __LINE__, ctx, NKikimrServices::BLOBSTORAGE);
}

// NOTES: we have 4 state functions, one of which is an error state (StateDatabaseError) and
// others are good: StateLocalRecovery, StateSyncGuidRecovery, StateNormal
// We switch between states in the following manner:
Expand Down Expand Up @@ -2622,6 +2638,7 @@ namespace NKikimr {
hFunc(NPDisk::TEvChunkForgetResult, Handle)
FFunc(TEvPrivate::EvCheckSnapshotExpiration, CheckSnapshotExpiration)
hFunc(TEvReplInvoke, Handle)
CFunc(TEvStartBalancing::EventType, RunBalancing)
)

STRICT_STFUNC(StateDatabaseError,
Expand Down Expand Up @@ -2730,6 +2747,7 @@ namespace NKikimr {
bool CommenceRepl = false;
TActorId ScrubId;
TActorId DefragId;
TActorId BalancingId;
bool HasUnreadableBlobs = false;
std::unique_ptr<TVDiskCompactionState> VDiskCompactionState;
TMemorizableControlWrapper EnableVPatch;
Expand Down
1 change: 1 addition & 0 deletions ydb/core/blobstorage/vdisk/skeleton/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ LIBRARY()

PEERDIR(
ydb/core/base
ydb/core/blobstorage/vdisk/balance
ydb/core/blobstorage/vdisk/hulldb/base
ydb/core/blobstorage/vdisk/hulldb/bulksst_add
ydb/core/blobstorage/vdisk/synclog
Expand Down
1 change: 1 addition & 0 deletions ydb/core/blobstorage/vdisk/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ END()

RECURSE(
anubis_osiris
balance
common
defrag
handoff
Expand Down
1 change: 1 addition & 0 deletions ydb/core/protos/feature_flags.proto
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,5 @@ message TFeatureFlags {
optional bool EnableTablePgTypes = 108 [default = false];
optional bool EnableLocalDBBtreeIndex = 109 [default = false];
optional bool EnablePDiskHighHDDInFlight = 110 [default = false];
optional bool UseVDisksBalancing = 111 [default = false];
}