Skip to content
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

Allow some quiet period before starting TestShard load #12887

Merged
merged 1 commit into from
Dec 24, 2024
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/protos/msgbus.proto
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ message TTestShardControlRequest {
optional uint32 PatchRequestsFractionPPM = 12;
optional uint32 PutTraceFractionPPM = 13;
optional uint32 PutTraceVerbosity = 14 [default = 15];
optional uint32 SecondsBeforeLoadStart = 15; // number of seconds to wait before starting load
}

optional uint64 TabletId = 1;
Expand Down
22 changes: 16 additions & 6 deletions ydb/core/test_tablet/load_actor_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ namespace NKikimr::NTestShard {

TLoadActor::TLoadActor(ui64 tabletId, ui32 generation, TActorId tablet,
const NKikimrClient::TTestShardControlRequest::TCmdInitialize& settings)
: TabletId(tabletId)
: TActor(&TThis::StateFunc)
, TabletId(tabletId)
, Generation(generation)
, Tablet(tablet)
, Settings(settings)
Expand All @@ -14,6 +15,17 @@ namespace NKikimr::NTestShard {
ClearKeys();
}

void TLoadActor::Registered(TActorSystem *sys, const TActorId& owner) {
TActor::Registered(sys, owner);
TabletActorId = owner;
auto ev = std::make_unique<IEventHandle>(TEvents::TSystem::Bootstrap, 0, SelfId(), owner, nullptr, 0);
if (Settings.HasSecondsBeforeLoadStart()) {
sys->Schedule(TDuration::Seconds(Settings.GetSecondsBeforeLoadStart()), ev.release());
} else {
sys->Send(ev.release());
}
}

void TLoadActor::ClearKeys() {
for (auto& [key, info] : Keys) {
Y_ABORT_UNLESS(info.ConfirmedState == ::NTestShard::TStateServer::CONFIRMED
Expand All @@ -25,18 +37,16 @@ namespace NKikimr::NTestShard {
ConfirmedKeys.clear();
}

void TLoadActor::Bootstrap(const TActorId& parentId) {
void TLoadActor::Bootstrap() {
STLOG(PRI_DEBUG, TEST_SHARD, TS31, "TLoadActor::Bootstrap", (TabletId, TabletId));
TabletActorId = parentId;
if (Settings.HasStorageServerHost()) {
Send(MakeStateServerInterfaceActorId(), new TEvStateServerConnect(Settings.GetStorageServerHost(),
Settings.GetStorageServerPort()));
Send(parentId, new TTestShard::TEvSwitchMode(TTestShard::EMode::STATE_SERVER_CONNECT));
Send(TabletActorId, new TTestShard::TEvSwitchMode(TTestShard::EMode::STATE_SERVER_CONNECT));
} else {
RunValidation(true);
}
NextWriteTimestamp = TActivationContext::Monotonic();
Become(&TThis::StateFunc);
}

void TLoadActor::PassAway() {
Expand All @@ -46,7 +56,7 @@ namespace NKikimr::NTestShard {
if (ValidationActorId) {
TActivationContext::Send(new IEventHandle(TEvents::TSystem::Poison, 0, ValidationActorId, SelfId(), nullptr, 0));
}
TActorBootstrapped::PassAway();
TActor::PassAway();
}

void TLoadActor::HandleWakeup() {
Expand Down
6 changes: 4 additions & 2 deletions ydb/core/test_tablet/load_actor_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace NKikimr::NTestShard {

class TLoadActor : public TActorBootstrapped<TLoadActor> {
class TLoadActor : public TActor<TLoadActor> {
const ui64 TabletId;
const ui32 Generation;
const TActorId Tablet;
Expand Down Expand Up @@ -58,14 +58,16 @@ namespace NKikimr::NTestShard {
TLoadActor(ui64 tabletId, ui32 generation, const TActorId tablet,
const NKikimrClient::TTestShardControlRequest::TCmdInitialize& settings);
~TLoadActor();
void Registered(TActorSystem *sys, const TActorId& owner) override;
void ClearKeys();
void Bootstrap(const TActorId& parentId);
void Bootstrap();
void PassAway() override;
void HandleWakeup();
void Action();
void Handle(TEvStateServerStatus::TPtr ev);

STRICT_STFUNC(StateFunc,
cFunc(TEvents::TSystem::Bootstrap, Bootstrap);
hFunc(TEvKeyValue::TEvResponse, Handle);
hFunc(NMon::TEvRemoteHttpInfo, Handle);
hFunc(TEvStateServerStatus, Handle);
Expand Down
Loading