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

Make coordination session ping period dependent on session timeout KIKIMR-20993 #1575

Merged
Merged
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
14 changes: 12 additions & 2 deletions ydb/services/kesus/grpc_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ namespace NKesus {
class TGRpcSessionActor
: public TActorBootstrapped<TGRpcSessionActor>
{
static constexpr TDuration MinPingPeriod = TDuration::MilliSeconds(10);
static constexpr TDuration MaxPingPeriod = TDuration::Seconds(5);

public:
using TRequest = Ydb::Coordination::SessionRequest;
using TResponse = Ydb::Coordination::SessionResponse;
Expand Down Expand Up @@ -132,6 +135,13 @@ class TGRpcSessionActor
return PassAway();
}

PingPeriod = TDuration::MilliSeconds(StartRequest->Record.session_start().timeout_millis() / 3);
if (PingPeriod > MaxPingPeriod) {
PingPeriod = MaxPingPeriod;
} else if (PingPeriod < MinPingPeriod) {
PingPeriod = MinPingPeriod;
}

KesusPath = StartRequest->Record.session_start().path();

auto resolve = MakeHolder<TEvKesusProxy::TEvResolveKesusProxy>(KesusPath);
Expand Down Expand Up @@ -540,8 +550,7 @@ class TGRpcSessionActor
ping->set_opaque(CurrentPingData);
Reply(std::move(response));

// TODO: configure timeout
Schedule(TDuration::MilliSeconds(5000), new TEvPrivate::TEvPingScheduled());
Schedule(PingPeriod, new TEvPrivate::TEvPingScheduled());
}

void Handle(const TEvPrivate::TEvPingScheduled::TPtr& ev) {
Expand Down Expand Up @@ -599,6 +608,7 @@ class TGRpcSessionActor
ui64 SessionId = 0;
bool SessionEstablished = false;
ui64 CurrentPingData = 0;
TDuration PingPeriod;
};

////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading