Skip to content

Commit b3e6533

Browse files
authored
Fix BSC vs Console interaction (merge from main #17752) (#17786)
1 parent 9dfc63f commit b3e6533

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

ydb/core/mind/bscontroller/console_interaction.cpp

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ namespace NKikimr::NBsController {
4444
void TBlobStorageController::TConsoleInteraction::Handle(TEvTabletPipe::TEvClientConnected::TPtr& /*ev*/) {
4545
}
4646

47-
void TBlobStorageController::TConsoleInteraction::Handle(TEvTabletPipe::TEvClientDestroyed::TPtr& /*ev*/) {
47+
void TBlobStorageController::TConsoleInteraction::Handle(TEvTabletPipe::TEvClientDestroyed::TPtr& ev) {
48+
STLOG(PRI_DEBUG, BS_CONTROLLER, BSC33, "Console pipe destroyed", (ConsolePipe, ConsolePipe),
49+
(ClientId, ev->Get()->ClientId), (Working, Working));
4850
ConsolePipe = {};
4951
if (Working) {
5052
if (ClientId) {
@@ -56,17 +58,13 @@ namespace NKikimr::NBsController {
5658
}
5759

5860
void TBlobStorageController::TConsoleInteraction::MakeGetBlock() {
61+
STLOG(PRI_DEBUG, BS_CONTROLLER, BSC34, "Issuing GetBlock for BSC");
5962
auto ev = std::make_unique<TEvBlobStorage::TEvGetBlock>(Self.TabletID(), TInstant::Max());
6063
auto bsProxyEv = CreateEventForBSProxy(Self.SelfId(), Self.Info()->GroupFor(0, Self.Executor()->Generation()),
6164
ev.release(), 0);
6265
TActivationContext::Schedule(TDuration::MilliSeconds(GetBlockBackoff.NextBackoffMs()), bsProxyEv);
6366
}
6467

65-
void TBlobStorageController::TConsoleInteraction::MakeRetrySession() {
66-
NeedRetrySession = false;
67-
Start();
68-
}
69-
7068
void TBlobStorageController::TConsoleInteraction::Handle(TEvBlobStorage::TEvControllerProposeConfigResponse::TPtr &ev) {
7169
if (!Working) {
7270
return;
@@ -186,8 +184,10 @@ namespace NKikimr::NBsController {
186184
}
187185

188186
void TBlobStorageController::TConsoleInteraction::Stop() {
187+
STLOG(PRI_DEBUG, BS_CONTROLLER, BSC35, "Stopping console interaction", (ConsolePipe, ConsolePipe), (Working, Working));
189188
if (ConsolePipe) {
190189
NTabletPipe::CloseClient(Self.SelfId(), ConsolePipe);
190+
ConsolePipe = {};
191191
}
192192
Working = false;
193193
}
@@ -200,8 +200,8 @@ namespace NKikimr::NBsController {
200200
auto& record = ev->Get()->Record;
201201
switch (auto status = record.GetStatus()) {
202202
case NKikimrBlobStorage::TEvControllerConsoleCommitResponse::SessionMismatch:
203+
NTabletPipe::CloseAndForgetClient(Self.SelfId(), ConsolePipe);
203204
MakeGetBlock();
204-
NeedRetrySession = true;
205205
break;
206206

207207
case NKikimrBlobStorage::TEvControllerConsoleCommitResponse::NotCommitted:
@@ -226,10 +226,13 @@ namespace NKikimr::NBsController {
226226
auto& record = ev->Get()->Record;
227227

228228
const bool reasonOngoingCommit = CommitInProgress || (ClientId && ClientId != ev->Sender);
229-
if (reasonOngoingCommit || (!Self.EnableConfigV2 && !record.GetSwitchEnableConfigV2())) {
229+
if (!ConsolePipe || reasonOngoingCommit || (!Self.EnableConfigV2 && !record.GetSwitchEnableConfigV2())) {
230230
// reply to newly came query
231231
const TActorId temp = std::exchange(ClientId, ev->Sender);
232-
if (reasonOngoingCommit) {
232+
if (!ConsolePipe) {
233+
IssueGRpcResponse(NKikimrBlobStorage::TEvControllerReplaceConfigResponse::SessionClosed,
234+
"connection to Console tablet terminated");
235+
} else if (reasonOngoingCommit) {
233236
IssueGRpcResponse(NKikimrBlobStorage::TEvControllerReplaceConfigResponse::OngoingCommit, "ongoing commit");
234237
} else {
235238
IssueGRpcResponse(NKikimrBlobStorage::TEvControllerReplaceConfigResponse::InvalidRequest, "configuration v2 is disabled", true);
@@ -400,6 +403,8 @@ namespace NKikimr::NBsController {
400403
validateConfigEv->Record.SetYAML(record.GetClusterYaml());
401404
validateConfigEv->Record.SetAllowUnknownFields(record.GetAllowUnknownFields());
402405
validateConfigEv->Record.SetBypassMetadataChecks(record.GetBypassMetadataChecks());
406+
STLOG(PRI_DEBUG, BS_CONTROLLER, BSC36, "Sending TEvControllerValidateConfigRequest to console",
407+
(ConsolePipe, ConsolePipe));
403408
NTabletPipe::SendData(Self.SelfId(), ConsolePipe, validateConfigEv.release());
404409
}
405410

@@ -451,8 +456,8 @@ namespace NKikimr::NBsController {
451456
auto& record = ev->Get()->Record;
452457
switch (auto status = record.GetStatus()) {
453458
case NKikimrBlobStorage::TEvControllerValidateConfigResponse::IdPipeServerMismatch:
459+
NTabletPipe::CloseAndForgetClient(Self.SelfId(), ConsolePipe);
454460
MakeGetBlock();
455-
NeedRetrySession = true;
456461
return;
457462

458463
case NKikimrBlobStorage::TEvControllerValidateConfigResponse::ConfigNotValid:
@@ -531,22 +536,25 @@ namespace NKikimr::NBsController {
531536
}
532537

533538
void TBlobStorageController::TConsoleInteraction::Handle(TEvBlobStorage::TEvGetBlockResult::TPtr& ev) {
539+
auto* msg = ev->Get();
540+
541+
STLOG(PRI_DEBUG, BS_CONTROLLER, BSC37, "TEvGetBlockResult received", (ConsolePipe, ConsolePipe),
542+
(Working, Working), (Status, msg->Status), (BlockedGeneration, msg->BlockedGeneration),
543+
(Generation, Self.Executor()->Generation()));
544+
534545
if (!Working) {
535546
return;
536547
}
537-
auto* msg = ev->Get();
538-
auto status = msg->Status;
548+
539549
auto blockedGeneration = msg->BlockedGeneration;
540550
auto generation = Self.Executor()->Generation();
541-
switch (status) {
551+
switch (msg->Status) {
542552
case NKikimrProto::OK:
543553
if (generation <= blockedGeneration) {
544-
Self.HandlePoison(TActivationContext::AsActorContext());
545-
return;
554+
return Self.HandlePoison(TActivationContext::AsActorContext());
546555
}
547-
if (generation == blockedGeneration + 1 && NeedRetrySession) {
548-
MakeRetrySession();
549-
return;
556+
if (generation == blockedGeneration + 1 && !ConsolePipe) {
557+
return Start();
550558
}
551559
Y_VERIFY_DEBUG_S(generation == blockedGeneration + 1, "BlockedGeneration#" << blockedGeneration
552560
<< " Tablet generation#" << generation);

ydb/core/mind/bscontroller/console_interaction.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ namespace NKikimr::NBsController {
4444
ui64 ExpectedValidationTimeoutCookie = 0;
4545
TBackoffTimer GetBlockBackoff{1, 1000};
4646
ui32 BlockedGeneration = 0;
47-
bool NeedRetrySession = false;
4847
bool Working = false;
4948
bool CommitInProgress = false;
5049
std::optional<bool> SwitchEnableConfigV2;
@@ -58,7 +57,6 @@ namespace NKikimr::NBsController {
5857

5958
void MakeCommitToConsole(TString& config, ui32 configVersion);
6059
void MakeGetBlock();
61-
void MakeRetrySession();
6260

6361
void IssueGRpcResponse(NKikimrBlobStorage::TEvControllerReplaceConfigResponse::EStatus status,
6462
std::optional<TString> errorReason = std::nullopt, bool disabledConfigV2 = false);

0 commit comments

Comments
 (0)