Skip to content

Commit f161e2b

Browse files
authored
[stable-25-1] Make reconnect to kesus work again (#18496)
2 parents 607408b + d2901c1 commit f161e2b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

ydb/core/quoter/kesus_quoter_proxy.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ class TKesusQuoterProxy : public TActorBootstrapped<TKesusQuoterProxy> {
289289
bool Connected = false;
290290
TInstant DisconnectTime;
291291
ui64 OfflineAllocationCookie = 0;
292+
ui64 KesusReconnectCount = 0;
292293

293294
TMap<TString, THolder<TResourceState>> Resources; // Map because iterators are needed to remain valid during insertions.
294295
THashMap<ui64, decltype(Resources)::iterator> ResIndex;
@@ -803,7 +804,11 @@ class TKesusQuoterProxy : public TActorBootstrapped<TKesusQuoterProxy> {
803804
SendToService(CreateUpdateEvent(TEvQuota::EUpdateState::Broken));
804805
} else {
805806
KESUS_PROXY_LOG_WARN("Failed to connect to tablet. Status: " << ev->Get()->Status);
806-
ConnectToKesus(true);
807+
if (!ConnectToKesus(true)) {
808+
KESUS_PROXY_LOG_WARN("Too many reconnect attempts, assuming kesus dead");
809+
SendToService(CreateUpdateEvent(TEvQuota::EUpdateState::Broken));
810+
KesusReconnectCount = 0;
811+
}
807812
}
808813
}
809814
}
@@ -1119,7 +1124,6 @@ class TKesusQuoterProxy : public TActorBootstrapped<TKesusQuoterProxy> {
11191124

11201125
NTabletPipe::TClientConfig GetPipeConnectionOptions(bool reconnection) {
11211126
NTabletPipe::TClientConfig cfg;
1122-
cfg.CheckAliveness = true;
11231127
cfg.RetryPolicy = {
11241128
.RetryLimitCount = 3u,
11251129
.DoFirstRetryInstantly = !reconnection
@@ -1134,9 +1138,13 @@ class TKesusQuoterProxy : public TActorBootstrapped<TKesusQuoterProxy> {
11341138
CookieToResourcePath.clear(); // we will resend all requests with new cookies
11351139
}
11361140

1137-
void ConnectToKesus(bool reconnection) {
1141+
bool ConnectToKesus(bool reconnection) {
11381142
if (reconnection) {
11391143
KESUS_PROXY_LOG_INFO("Reconnecting to kesus");
1144+
++KesusReconnectCount;
1145+
if (KesusReconnectCount > 5) {
1146+
return false;
1147+
}
11401148
} else {
11411149
KESUS_PROXY_LOG_DEBUG("Connecting to kesus");
11421150
}
@@ -1149,6 +1157,7 @@ class TKesusQuoterProxy : public TActorBootstrapped<TKesusQuoterProxy> {
11491157
GetKesusTabletId(),
11501158
GetPipeConnectionOptions(reconnection)));
11511159
Connected = false;
1160+
return true;
11521161
}
11531162

11541163
void PassAway() override {

ydb/core/quoter/ut_helpers.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void TKesusQuoterTestSetup::SetupLogging() {
4141
Server->GetRuntime()->SetLogPriority(NKikimrServices::KESUS_TABLET, NActors::NLog::PRI_TRACE);
4242
Server->GetRuntime()->SetLogPriority(NKikimrServices::QUOTER_SERVICE, NActors::NLog::PRI_TRACE);
4343
Server->GetRuntime()->SetLogPriority(NKikimrServices::QUOTER_PROXY, NActors::NLog::PRI_TRACE);
44+
Server->GetRuntime()->SetLogPriority(NKikimrServices::PIPE_CLIENT, NActors::NLog::PRI_TRACE);
4445
}
4546

4647
void TKesusQuoterTestSetup::RegisterQuoterService() {

0 commit comments

Comments
 (0)