diff options
author | serg-belyakov <serg-belyakov@yandex-team.com> | 2023-12-01 19:31:51 +0300 |
---|---|---|
committer | serg-belyakov <serg-belyakov@yandex-team.com> | 2023-12-01 23:39:55 +0300 |
commit | 248b9679b2ff3239c897c81f7865a97b56d970c6 (patch) | |
tree | 568377d330ee5060e0533897e7711f02a6ffe3a2 | |
parent | 751584d4216aba6f6b03ccef80105a07bad32c94 (diff) | |
download | ydb-248b9679b2ff3239c897c81f7865a97b56d970c6.tar.gz |
Fix memory issue, launch load tablets with different ids on different nodes, KIKIMR-20348
Fix memory issue, launch load tablets with different ids on different nodes
Launch tablets with different ids on different nodes
-rw-r--r-- | ydb/core/load_test/events.h | 10 | ||||
-rw-r--r-- | ydb/core/load_test/group_write.cpp | 43 | ||||
-rw-r--r-- | ydb/core/load_test/service_actor.cpp | 9 | ||||
-rw-r--r-- | ydb/core/protos/load_test.proto | 5 |
4 files changed, 57 insertions, 10 deletions
diff --git a/ydb/core/load_test/events.h b/ydb/core/load_test/events.h index d124d3fc01..86e712916e 100644 --- a/ydb/core/load_test/events.h +++ b/ydb/core/load_test/events.h @@ -6,6 +6,8 @@ #include <library/cpp/monlib/dynamic_counters/percentile/percentile_lg.h> #include <library/cpp/json/writer/json_value.h> +#include <google/protobuf/text_format.h> + namespace NKikimr { struct TEvLoad { enum EEv { @@ -91,7 +93,13 @@ struct TEvLoad { struct TEvNodeFinishResponse : public TEventPB<TEvNodeFinishResponse, NKikimr::TEvNodeFinishResponse, EvNodeFinishResponse> - {}; + { + TString ToString() const { + TString str; + google::protobuf::TextFormat::PrintToString(Record, &str); + return str; + } + }; struct TEvYqlSingleQueryResponse : public TEventLocal<TEvYqlSingleQueryResponse, TEvLoad::EvYqlSingleQueryResponse> { TString Result; // empty in case if there is an error diff --git a/ydb/core/load_test/group_write.cpp b/ydb/core/load_test/group_write.cpp index 8592522e06..59921cef21 100644 --- a/ydb/core/load_test/group_write.cpp +++ b/ydb/core/load_test/group_write.cpp @@ -125,9 +125,9 @@ class TLogWriterLoadTestActor : public TActorBootstrapped<TLogWriterLoadTestActo , RequestRateAtStart((EpochDuration / TDuration::Seconds(1)) * requestsPerSecondAtStart) , RequestRateOnFinish((EpochDuration / TDuration::Seconds(1)) * requestsPerSecondOnFinish) , CurrentEpochEnd(now) - , PlannedForCurrentEpoch(std::max(1., CalculateRequestRate(now))) , LoadStart(now) - , LoadDuration(duration) { + , LoadDuration(duration) + , PlannedForCurrentEpoch(std::max(1., CalculateRequestRate(now))) { CalculateDelayForNextRequest(now); } @@ -142,12 +142,12 @@ class TLogWriterLoadTestActor : public TActorBootstrapped<TLogWriterLoadTestActo TDuration CurrentDelay = TDuration::Seconds(0); TMonotonic Now = TMonotonic::Max(); - double PlannedForCurrentEpoch; - ui32 ResponsesAwaiting = 0; - const TMonotonic LoadStart; const TMaybe<TDuration> LoadDuration; + double PlannedForCurrentEpoch; + ui32 ResponsesAwaiting = 0; + double CalculateRequestRate(TMonotonic now) { double ratio = LoadDuration ? (now - LoadStart) / *LoadDuration : 0; return ratio * (RequestRateOnFinish - RequestRateAtStart) + RequestRateAtStart; @@ -887,6 +887,8 @@ class TLogWriterLoadTestActor : public TActorBootstrapped<TLogWriterLoadTestActo TMonotonic LastScheduleTime = TMonotonic::Max(); TMonotonic LastWakeupTime = TMonotonic::Max(); + static constexpr ui64 DefaultTabletId = 5000; + public: static constexpr NKikimrServices::TActivity::EType ActorActivityType() { return NKikimrServices::TActivity::BS_LOAD_ACTOR; @@ -902,6 +904,8 @@ public: if (cmd.HasDurationSeconds()) { TestDuration = TDuration::Seconds(cmd.GetDurationSeconds()); } + + std::unordered_map<TString, ui64> tabletIds; for (const auto& profile : cmd.GetTablets()) { if (!profile.TabletsSize()) { ythrow TLoadActorException() << "TPerTabletProfile.Tablets must have at least one item"; @@ -978,10 +982,33 @@ public: }); } - if (!tablet.HasTabletId() || !tablet.HasChannel() || !tablet.HasGroupId()) { - ythrow TLoadActorException() << "TTabletInfo.{TabletId,Channel,GroupId} fields are mandatory"; + if (!tablet.HasChannel() || !tablet.HasGroupId()) { + ythrow TLoadActorException() << "TTabletInfo.{Channel,GroupId} fields are mandatory"; } - TabletWriters.emplace_back(std::make_unique<TTabletWriter>(Tag, counters, WakeupQueue, QueryDispatcher, tablet.GetTabletId(), + if (!tablet.HasTabletName() && !tablet.HasTabletId()) { + ythrow TLoadActorException() << "One of TTabletInfo.{TabletName,TabletId} fields must be specified"; + } + + ui64 tabletId; + if (tablet.HasTabletId()) { + tabletId = tablet.GetTabletId(); + } else if (tablet.HasTabletName()) { + TString name = tablet.GetTabletName(); + auto it = tabletIds.find(name); + if (it != tabletIds.end()) { + tabletId = it->second; + } else { + tabletId = THash<TString>{}(name) & ((1 << 20) - 1); + tabletId = tabletId << 10 + tag; + tabletId = tabletId << 10 + Parent.NodeId(); + tabletId = MakeTabletID(0, 0, tabletId); + tabletIds[name] = tabletId; + } + } else { + Y_FAIL(); + } + + TabletWriters.emplace_back(std::make_unique<TTabletWriter>(Tag, counters, WakeupQueue, QueryDispatcher, tabletId, tablet.GetChannel(), tablet.HasGeneration() ? TMaybe<ui32>(tablet.GetGeneration()) : TMaybe<ui32>(), tablet.GetGroupId(), putHandleClass, writeSettings, getHandleClass, readSettings, diff --git a/ydb/core/load_test/service_actor.cpp b/ydb/core/load_test/service_actor.cpp index bd937d5037..07fa8c1e5f 100644 --- a/ydb/core/load_test/service_actor.cpp +++ b/ydb/core/load_test/service_actor.cpp @@ -461,6 +461,14 @@ public: Send(ev->Sender, response.release()); } + void Handle(TEvLoad::TEvLoadTestResponse::TPtr& ev) { + if (ev->Get()->Record.GetStatus() != NMsgBusProxy::MSTATUS_OK) { + LOG_E("Receieved non-OK LoadTestResponse from another node, Record# " << ev->ToString()); + } else { + LOG_N("Receieved OK LoadTestResponse from another node# " << ev->ToString()); + } + } + ui64 ProcessCmd(const NKikimr::TEvLoadTestRequest& record) { ui64 tag = 0; if (record.Command_case() != TEvLoadTestRequest::CommandCase::kStop) { @@ -1317,6 +1325,7 @@ public: STRICT_STFUNC(StateFunc, hFunc(TEvLoad::TEvLoadTestRequest, Handle) + hFunc(TEvLoad::TEvLoadTestResponse, Handle) hFunc(TEvLoad::TEvLoadTestFinished, Handle) hFunc(TEvLoad::TEvNodeFinishResponse, Handle) hFunc(NMon::TEvHttpInfo, Handle) diff --git a/ydb/core/protos/load_test.proto b/ydb/core/protos/load_test.proto index 6dad8c06ed..3bc3bb84b7 100644 --- a/ydb/core/protos/load_test.proto +++ b/ydb/core/protos/load_test.proto @@ -39,7 +39,10 @@ message TEvLoadTestRequest { optional NKikimrBlobStorage.EPutHandleClass PutHandleClass = 4; } message TTabletInfo { - optional uint64 TabletId = 1; + oneof Id { + uint64 TabletId = 8; + string TabletName = 7; // only used to distinguish different tablets, will be reassigned + } optional uint32 Channel = 2; optional uint32 GroupId = 3; optional uint32 Generation = 4; |