Skip to content

Commit d2901c1

Browse files
committed
Make reconnect to kesus work again (#18269)
1 parent 9981c50 commit d2901c1

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

ydb/core/quoter/kesus_quoter_proxy.cpp

Lines changed: 12 additions & 2 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
}
@@ -1133,9 +1138,13 @@ class TKesusQuoterProxy : public TActorBootstrapped<TKesusQuoterProxy> {
11331138
CookieToResourcePath.clear(); // we will resend all requests with new cookies
11341139
}
11351140

1136-
void ConnectToKesus(bool reconnection) {
1141+
bool ConnectToKesus(bool reconnection) {
11371142
if (reconnection) {
11381143
KESUS_PROXY_LOG_INFO("Reconnecting to kesus");
1144+
++KesusReconnectCount;
1145+
if (KesusReconnectCount > 5) {
1146+
return false;
1147+
}
11391148
} else {
11401149
KESUS_PROXY_LOG_DEBUG("Connecting to kesus");
11411150
}
@@ -1148,6 +1157,7 @@ class TKesusQuoterProxy : public TActorBootstrapped<TKesusQuoterProxy> {
11481157
GetKesusTabletId(),
11491158
GetPipeConnectionOptions(reconnection)));
11501159
Connected = false;
1160+
return true;
11511161
}
11521162

11531163
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)