diff --git a/ydb/core/mind/hive/hive_impl.cpp b/ydb/core/mind/hive/hive_impl.cpp index 553dd46135a5..b421e11757cc 100644 --- a/ydb/core/mind/hive/hive_impl.cpp +++ b/ydb/core/mind/hive/hive_impl.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -96,10 +97,12 @@ void THive::RestartPipeTx(ui64 tabletId) { bool THive::TryToDeleteNode(TNodeInfo* node) { if (node->CanBeDeleted()) { + BLOG_I("TryToDeleteNode(" << node->Id << "): deleting"); DeleteNode(node->Id); return true; } if (!node->DeletionScheduled) { + BLOG_D("TryToDeleteNode(" << node->Id << "): waiting " << GetNodeDeletePeriod()); Schedule(GetNodeDeletePeriod(), new TEvPrivate::TEvDeleteNode(node->Id)); node->DeletionScheduled = true; } @@ -987,8 +990,9 @@ void THive::OnActivateExecutor(const TActorContext&) { BuildLocalConfig(); ClusterConfig = AppData()->HiveConfig; SpreadNeighbours = ClusterConfig.GetSpreadNeighbours(); + NodeBrokerEpoch = TDuration::MicroSeconds(NKikimrNodeBroker::TConfig().GetEpochDuration()); Send(NConsole::MakeConfigsDispatcherID(SelfId().NodeId()), - new NConsole::TEvConfigsDispatcher::TEvSetConfigSubscriptionRequest(NKikimrConsole::TConfigItem::HiveConfigItem)); + new NConsole::TEvConfigsDispatcher::TEvSetConfigSubscriptionRequest({NKikimrConsole::TConfigItem::HiveConfigItem, NKikimrConsole::TConfigItem::NodeBrokerConfigItem})); Execute(CreateInitScheme()); if (!ResponsivenessPinger) { ResponsivenessPinger = new TTabletResponsivenessPinger(TabletCounters->Simple()[NHive::COUNTER_RESPONSE_TIME_USEC], TDuration::Seconds(1)); @@ -2208,7 +2212,9 @@ void THive::Handle(TEvHive::TEvInitiateTabletExternalBoot::TPtr& ev) { void THive::Handle(NConsole::TEvConsole::TEvConfigNotificationRequest::TPtr& ev) { const NKikimrConsole::TConfigNotificationRequest& record = ev->Get()->Record; ClusterConfig = record.GetConfig().GetHiveConfig(); - BLOG_D("Received TEvConsole::TEvConfigNotificationRequest with update of cluster config: " << ClusterConfig.ShortDebugString()); + NodeBrokerEpoch = TDuration::MicroSeconds(record.GetConfig().GetNodeBrokerConfig().GetEpochDuration()); + BLOG_D("Received TEvConsole::TEvConfigNotificationRequest with update of cluster config: " << ClusterConfig.ShortDebugString() + << "; " << record.GetConfig().GetNodeBrokerConfig().ShortDebugString()); BuildCurrentConfig(); Send(ev->Sender, new NConsole::TEvConsole::TEvConfigNotificationResponse(record), 0, ev->Cookie); } diff --git a/ydb/core/mind/hive/hive_impl.h b/ydb/core/mind/hive/hive_impl.h index 16f972b0082b..24edd21f968d 100644 --- a/ydb/core/mind/hive/hive_impl.h +++ b/ydb/core/mind/hive/hive_impl.h @@ -445,6 +445,7 @@ class THive : public TActor, public TTabletExecutedFlat, public THiveShar NKikimrConfig::THiveConfig ClusterConfig; NKikimrConfig::THiveConfig DatabaseConfig; + TDuration NodeBrokerEpoch; std::unordered_map TabletLimit; // built from CurrentConfig std::unordered_map DefaultDataCentersPreference; std::unordered_map> RegisteredDataCenterNodes; @@ -739,7 +740,11 @@ TTabletInfo* FindTabletEvenInDeleting(TTabletId tabletId, TFollowerId followerId } TDuration GetNodeDeletePeriod() const { - return TDuration::Seconds(CurrentConfig.GetNodeDeletePeriod()); + if (CurrentConfig.HasNodeDeletePeriod()) { + return TDuration::Seconds(CurrentConfig.GetNodeDeletePeriod()); + } else { + return NodeBrokerEpoch; + } } ui64 GetDrainInflight() const { diff --git a/ydb/core/mind/hive/tx__load_everything.cpp b/ydb/core/mind/hive/tx__load_everything.cpp index f8a2e3ef74d8..710a14d2bc38 100644 --- a/ydb/core/mind/hive/tx__load_everything.cpp +++ b/ydb/core/mind/hive/tx__load_everything.cpp @@ -338,9 +338,9 @@ class TTxLoadEverything : public TTransactionBase { // it's safe to call here, because there is no any tablets in the node yet node.BecomeDisconnected(); } - if (node.CanBeDeleted()) { + if (Self->TryToDeleteNode(&node)) { + // node is deleted from hashmap db.Table().Key(nodeId).Delete(); - Self->Nodes.erase(nodeId); } else if (node.IsUnknown() && node.LocationAcquired) { Self->AddRegisteredDataCentersNode(node.Location.GetDataCenterId(), node.Id); } diff --git a/ydb/core/protos/config.proto b/ydb/core/protos/config.proto index cf823c864767..c58f1d228eda 100644 --- a/ydb/core/protos/config.proto +++ b/ydb/core/protos/config.proto @@ -1438,7 +1438,7 @@ message THiveConfig { optional double MinPeriodBetweenReassign = 33 [default = 300.0]; // seconds optional double TabletRestartWatchPeriod = 34 [default = 3600.0]; // seconds optional double NodeRestartWatchPeriod = 35 [default = 3600.0]; // seconds - optional uint64 NodeDeletePeriod = 36 [default = 14400]; // seconds + optional uint64 NodeDeletePeriod = 36 [default = 3600]; // seconds repeated THiveTabletLimit DefaultTabletLimit = 37; repeated THiveTabletPreference DefaultTabletPreference = 38; optional uint64 SystemTabletCategoryId = 39 [default = 1];