Skip to content

Commit

Permalink
Support distconf shutdown (#13351)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvru authored Jan 14, 2025
1 parent fc474d1 commit 3d0c4ef
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 18 deletions.
17 changes: 15 additions & 2 deletions ydb/core/blobstorage/nodewarden/distconf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ namespace NKikimr::NStorage {
ProposedStorageConfig.reset();
}

Send(MakeBlobStorageNodeWardenID(SelfId().NodeId()), new TEvNodeWardenStorageConfig(*StorageConfig,
ProposedStorageConfig ? &ProposedStorageConfig.value() : nullptr));
ReportStorageConfigToNodeWarden(0);

if (IsSelfStatic) {
PersistConfig({});
Expand Down Expand Up @@ -290,6 +289,20 @@ namespace NKikimr::NStorage {
}
}

void TDistributedConfigKeeper::ReportStorageConfigToNodeWarden(ui64 cookie) {
Y_ABORT_UNLESS(StorageConfig);
const TActorId wardenId = MakeBlobStorageNodeWardenID(SelfId().NodeId());
const bool distconfEnabled = StorageConfig->GetSelfManagementConfig().GetEnabled();
const NKikimrBlobStorage::TStorageConfig *config = distconfEnabled
? &StorageConfig.value()
: &BaseConfig;
const NKikimrBlobStorage::TStorageConfig *proposedConfig = ProposedStorageConfig && distconfEnabled
? &ProposedStorageConfig.value()
: nullptr;
auto ev = std::make_unique<TEvNodeWardenStorageConfig>(*config, proposedConfig);
Send(wardenId, ev.release(), 0, cookie);
}

STFUNC(TDistributedConfigKeeper::StateFunc) {
STLOG(PRI_DEBUG, BS_NODE, NWDC15, "StateFunc", (Type, ev->GetTypeRewrite()), (Sender, ev->Sender),
(SessionId, ev->InterconnectSession), (Cookie, ev->Cookie));
Expand Down
1 change: 1 addition & 0 deletions ydb/core/blobstorage/nodewarden/distconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ namespace NKikimr::NStorage {
void Halt(); // cease any distconf activity, unbind and reject any bindings
bool ApplyStorageConfig(const NKikimrBlobStorage::TStorageConfig& config);
void HandleConfigConfirm(STATEFN_SIG);
void ReportStorageConfigToNodeWarden(ui64 cookie);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PDisk configuration retrieval and storing
Expand Down
4 changes: 1 addition & 3 deletions ydb/core/blobstorage/nodewarden/distconf_fsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,7 @@ namespace NKikimr::NStorage {
// issue notification to node warden
if (StorageConfig && StorageConfig->GetGeneration() &&
StorageConfig->GetGeneration() < ProposedStorageConfig->GetGeneration()) {
const TActorId wardenId = MakeBlobStorageNodeWardenID(SelfId().NodeId());
auto ev = std::make_unique<TEvNodeWardenStorageConfig>(*StorageConfig, &ProposedStorageConfig.value());
Send(wardenId, ev.release(), 0, cookie);
ReportStorageConfigToNodeWarden(cookie);
++task.AsyncOperationsPending;
++ProposedStorageConfigCookieUsage;
}
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/blobstorage/nodewarden/distconf_invoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ namespace NKikimr::NStorage {

if (Self->StorageConfigYamlVersion && newYamlVersion != *Self->StorageConfigYamlVersion + 1) {
return FinishWithError(TResult::ERROR, TStringBuilder() << "version must be increasing by one"
<< " new version# " << newYamlVersion << " expected version# " << *Self->StorageConfigYamlVersion);
<< " new version# " << newYamlVersion << " expected version# " << *Self->StorageConfigYamlVersion + 1);
}

TString errorReason;
Expand Down
24 changes: 12 additions & 12 deletions ydb/core/blobstorage/nodewarden/node_warden_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,16 +1230,16 @@ bool NKikimr::NStorage::DeriveStorageConfig(const NKikimrConfig::TAppConfig& app
if (domains.DomainSize() == 1) {
const auto& domain = domains.GetDomain(0);

auto updateConfig = [&](bool needMerge, auto *to, const auto& from) {
auto updateConfig = [&](bool needMerge, auto *to, const auto& from, const char *entity) {
if (needMerge) {
char prefix[TActorId::MaxServiceIDLength] = {0};
auto toInfo = BuildStateStorageInfo(prefix, *to);
auto fromInfo = BuildStateStorageInfo(prefix, from);
if (toInfo->NToSelect != fromInfo->NToSelect) {
*errorReason = "NToSelect differs";
return false;
} else if (toInfo->SelectAllReplicas() != fromInfo->SelectAllReplicas()) {
*errorReason = "StateStorage rings differ";
char toPrefix[TActorId::MaxServiceIDLength] = {0};
char fromPrefix[TActorId::MaxServiceIDLength] = {0};
auto toInfo = BuildStateStorageInfo(toPrefix, *to);
auto fromInfo = BuildStateStorageInfo(fromPrefix, from);
if (toInfo->NToSelect != fromInfo->NToSelect || toInfo->SelectAllReplicas() != fromInfo->SelectAllReplicas()) {
*errorReason = TStringBuilder() << entity << " NToSelect/rings differs"
<< " from# " << SingleLineProto(from)
<< " to# " << SingleLineProto(*to);
return false;
}
}
Expand All @@ -1254,9 +1254,9 @@ bool NKikimr::NStorage::DeriveStorageConfig(const NKikimrConfig::TAppConfig& app
const bool hadStateStorageConfig = config->HasStateStorageConfig();
const bool hadStateStorageBoardConfig = config->HasStateStorageBoardConfig();
const bool hadSchemeBoardConfig = config->HasSchemeBoardConfig();
if (!updateConfig(hadStateStorageConfig, config->MutableStateStorageConfig(), ss) ||
!updateConfig(hadStateStorageBoardConfig, config->MutableStateStorageBoardConfig(), ss) ||
!updateConfig(hadSchemeBoardConfig, config->MutableSchemeBoardConfig(), ss)) {
if (!updateConfig(hadStateStorageConfig, config->MutableStateStorageConfig(), ss, "StateStorage") ||
!updateConfig(hadStateStorageBoardConfig, config->MutableStateStorageBoardConfig(), ss, "StateStorageBoard") ||
!updateConfig(hadSchemeBoardConfig, config->MutableSchemeBoardConfig(), ss, "SchemeBoard")) {
return false;
}
break;
Expand Down

0 comments on commit 3d0c4ef

Please sign in to comment.