Skip to content

Commit 18ed18e

Browse files
authored
Allow some quiet period before starting TestShard load (#12887)
1 parent c7b02fe commit 18ed18e

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

ydb/core/protos/msgbus.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ message TTestShardControlRequest {
704704
optional uint32 PatchRequestsFractionPPM = 12;
705705
optional uint32 PutTraceFractionPPM = 13;
706706
optional uint32 PutTraceVerbosity = 14 [default = 15];
707+
optional uint32 SecondsBeforeLoadStart = 15; // number of seconds to wait before starting load
707708
}
708709

709710
optional uint64 TabletId = 1;

ydb/core/test_tablet/load_actor_impl.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ namespace NKikimr::NTestShard {
44

55
TLoadActor::TLoadActor(ui64 tabletId, ui32 generation, TActorId tablet,
66
const NKikimrClient::TTestShardControlRequest::TCmdInitialize& settings)
7-
: TabletId(tabletId)
7+
: TActor(&TThis::StateFunc)
8+
, TabletId(tabletId)
89
, Generation(generation)
910
, Tablet(tablet)
1011
, Settings(settings)
@@ -14,6 +15,17 @@ namespace NKikimr::NTestShard {
1415
ClearKeys();
1516
}
1617

18+
void TLoadActor::Registered(TActorSystem *sys, const TActorId& owner) {
19+
TActor::Registered(sys, owner);
20+
TabletActorId = owner;
21+
auto ev = std::make_unique<IEventHandle>(TEvents::TSystem::Bootstrap, 0, SelfId(), owner, nullptr, 0);
22+
if (Settings.HasSecondsBeforeLoadStart()) {
23+
sys->Schedule(TDuration::Seconds(Settings.GetSecondsBeforeLoadStart()), ev.release());
24+
} else {
25+
sys->Send(ev.release());
26+
}
27+
}
28+
1729
void TLoadActor::ClearKeys() {
1830
for (auto& [key, info] : Keys) {
1931
Y_ABORT_UNLESS(info.ConfirmedState == ::NTestShard::TStateServer::CONFIRMED
@@ -25,18 +37,16 @@ namespace NKikimr::NTestShard {
2537
ConfirmedKeys.clear();
2638
}
2739

28-
void TLoadActor::Bootstrap(const TActorId& parentId) {
40+
void TLoadActor::Bootstrap() {
2941
STLOG(PRI_DEBUG, TEST_SHARD, TS31, "TLoadActor::Bootstrap", (TabletId, TabletId));
30-
TabletActorId = parentId;
3142
if (Settings.HasStorageServerHost()) {
3243
Send(MakeStateServerInterfaceActorId(), new TEvStateServerConnect(Settings.GetStorageServerHost(),
3344
Settings.GetStorageServerPort()));
34-
Send(parentId, new TTestShard::TEvSwitchMode(TTestShard::EMode::STATE_SERVER_CONNECT));
45+
Send(TabletActorId, new TTestShard::TEvSwitchMode(TTestShard::EMode::STATE_SERVER_CONNECT));
3546
} else {
3647
RunValidation(true);
3748
}
3849
NextWriteTimestamp = TActivationContext::Monotonic();
39-
Become(&TThis::StateFunc);
4050
}
4151

4252
void TLoadActor::PassAway() {
@@ -46,7 +56,7 @@ namespace NKikimr::NTestShard {
4656
if (ValidationActorId) {
4757
TActivationContext::Send(new IEventHandle(TEvents::TSystem::Poison, 0, ValidationActorId, SelfId(), nullptr, 0));
4858
}
49-
TActorBootstrapped::PassAway();
59+
TActor::PassAway();
5060
}
5161

5262
void TLoadActor::HandleWakeup() {

ydb/core/test_tablet/load_actor_impl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace NKikimr::NTestShard {
1010

11-
class TLoadActor : public TActorBootstrapped<TLoadActor> {
11+
class TLoadActor : public TActor<TLoadActor> {
1212
const ui64 TabletId;
1313
const ui32 Generation;
1414
const TActorId Tablet;
@@ -58,14 +58,16 @@ namespace NKikimr::NTestShard {
5858
TLoadActor(ui64 tabletId, ui32 generation, const TActorId tablet,
5959
const NKikimrClient::TTestShardControlRequest::TCmdInitialize& settings);
6060
~TLoadActor();
61+
void Registered(TActorSystem *sys, const TActorId& owner) override;
6162
void ClearKeys();
62-
void Bootstrap(const TActorId& parentId);
63+
void Bootstrap();
6364
void PassAway() override;
6465
void HandleWakeup();
6566
void Action();
6667
void Handle(TEvStateServerStatus::TPtr ev);
6768

6869
STRICT_STFUNC(StateFunc,
70+
cFunc(TEvents::TSystem::Bootstrap, Bootstrap);
6971
hFunc(TEvKeyValue::TEvResponse, Handle);
7072
hFunc(NMon::TEvRemoteHttpInfo, Handle);
7173
hFunc(TEvStateServerStatus, Handle);

0 commit comments

Comments
 (0)