@@ -43,6 +43,8 @@ namespace NQuoter {
43
43
44
44
namespace TEvKesus = NKesus::TEvKesus;
45
45
46
+ const ui64 KesusReconnectLimit = 5 ;
47
+
46
48
class TKesusQuoterProxy : public TActorBootstrapped <TKesusQuoterProxy> {
47
49
struct TResourceState {
48
50
const TString Resource;
@@ -797,15 +799,18 @@ class TKesusQuoterProxy : public TActorBootstrapped<TKesusQuoterProxy> {
797
799
if (ev->Get ()->Status == NKikimrProto::OK) {
798
800
KESUS_PROXY_LOG_DEBUG (" Successfully connected to tablet" );
799
801
Connected = true ;
802
+ KesusReconnectCount = 0 ;
800
803
SubscribeToAllResources ();
801
804
} else {
802
805
if (ev->Get ()->Dead ) {
803
806
KESUS_PROXY_LOG_WARN (" Tablet doesn't exist" );
804
807
SendToService (CreateUpdateEvent (TEvQuota::EUpdateState::Broken));
805
808
} else {
806
809
KESUS_PROXY_LOG_WARN (" Failed to connect to tablet. Status: " << ev->Get ()->Status );
807
- if (!ConnectToKesus (true )) {
808
- KESUS_PROXY_LOG_WARN (" Too many reconnect attempts, assuming kesus dead" );
810
+ if (++KesusReconnectCount <= KesusReconnectLimit) {
811
+ ConnectToKesus (true );
812
+ } else {
813
+ KESUS_PROXY_LOG_WARN (" Too many reconnect attempts in a row, assuming kesus dead" );
809
814
SendToService (CreateUpdateEvent (TEvQuota::EUpdateState::Broken));
810
815
KesusReconnectCount = 0 ;
811
816
}
@@ -1122,7 +1127,7 @@ class TKesusQuoterProxy : public TActorBootstrapped<TKesusQuoterProxy> {
1122
1127
return KesusInfo->Description .GetKesusTabletId ();
1123
1128
}
1124
1129
1125
- NTabletPipe::TClientConfig GetPipeConnectionOptions (bool reconnection) {
1130
+ static NTabletPipe::TClientConfig GetPipeConnectionOptions (bool reconnection) {
1126
1131
NTabletPipe::TClientConfig cfg;
1127
1132
cfg.RetryPolicy = {
1128
1133
.RetryLimitCount = 3u ,
@@ -1138,13 +1143,9 @@ class TKesusQuoterProxy : public TActorBootstrapped<TKesusQuoterProxy> {
1138
1143
CookieToResourcePath.clear (); // we will resend all requests with new cookies
1139
1144
}
1140
1145
1141
- bool ConnectToKesus (bool reconnection) {
1146
+ void ConnectToKesus (bool reconnection) {
1142
1147
if (reconnection) {
1143
1148
KESUS_PROXY_LOG_INFO (" Reconnecting to kesus" );
1144
- ++KesusReconnectCount;
1145
- if (KesusReconnectCount > 5 ) {
1146
- return false ;
1147
- }
1148
1149
} else {
1149
1150
KESUS_PROXY_LOG_DEBUG (" Connecting to kesus" );
1150
1151
}
@@ -1157,7 +1158,6 @@ class TKesusQuoterProxy : public TActorBootstrapped<TKesusQuoterProxy> {
1157
1158
GetKesusTabletId (),
1158
1159
GetPipeConnectionOptions (reconnection)));
1159
1160
Connected = false ;
1160
- return true ;
1161
1161
}
1162
1162
1163
1163
void PassAway () override {
0 commit comments