diff options
author | serg-belyakov <[email protected]> | 2023-10-18 17:51:49 +0300 |
---|---|---|
committer | serg-belyakov <[email protected]> | 2023-10-18 18:57:20 +0300 |
commit | 3eee1bccd54cd7ea18088159b2909f06c48fbb5f (patch) | |
tree | 5eb83a870f068adde33fa2b04a40c953965ad5e2 | |
parent | c818a211e33e13006af5e69d2167a6b5390b11f8 (diff) |
Do not reuse ids of expired nodes outside allowed interval, KIKIMR-19726
Check that dynnode id is in allowed interval on applying epoch diff
-rw-r--r-- | ydb/core/mind/node_broker.cpp | 2 | ||||
-rw-r--r-- | ydb/core/mind/node_broker_ut.cpp | 42 |
2 files changed, 43 insertions, 1 deletions
diff --git a/ydb/core/mind/node_broker.cpp b/ydb/core/mind/node_broker.cpp index efb9be1bd5f..5ec440fb1c5 100644 --- a/ydb/core/mind/node_broker.cpp +++ b/ydb/core/mind/node_broker.cpp @@ -347,7 +347,7 @@ void TNodeBroker::ApplyStateDiff(const TStateDiff &diff) "Remove node " << it->second.IdString()); ExpiredNodes.erase(it); - if (!IsBannedId(id) && NodeIdDomain(id) == DomainId) + if (!IsBannedId(id) && NodeIdDomain(id) == DomainId && id >= MinDynamicId && id <= MaxDynamicId) FreeIds.Set(id); } diff --git a/ydb/core/mind/node_broker_ut.cpp b/ydb/core/mind/node_broker_ut.cpp index 7da8aa39b43..db9ca8c14f0 100644 --- a/ydb/core/mind/node_broker_ut.cpp +++ b/ydb/core/mind/node_broker_ut.cpp @@ -1238,6 +1238,48 @@ Y_UNIT_TEST_SUITE(TNodeBrokerTest) { CheckLeaseExtension(runtime, sender, 1024, TStatus::OK, epoch); CheckLeaseExtension(runtime, sender, 1088, TStatus::OK, epoch); } + + Y_UNIT_TEST(DoNotReuseDynnodeIdsBelowMinDynamicNodeId) + { + TTestBasicRuntime runtime(8, false); + Setup(runtime); + TActorId sender = runtime.AllocateEdgeActor(); + + // There should be no dynamic nodes initially. + auto epoch = GetEpoch(runtime, sender); + + // Register node 1024. + CheckRegistration(runtime, sender, "host1", 1001, "host1.yandex.net", "1.2.3.4", + 1, 2, 3, 4, TStatus::OK, 1024, epoch.GetNextEnd()); + + // Update config and restart NodeBroker + auto dnConfig = runtime.GetAppData().DynamicNameserviceConfig; + dnConfig->MinDynamicNodeId += 64; + dnConfig->MaxDynamicNodeId += 64; + RestartNodeBroker(runtime); + + // Wait until epoch expiration. + WaitForEpochUpdate(runtime, sender); + epoch = GetEpoch(runtime, sender); + CheckLeaseExtension(runtime, sender, 1024, TStatus::OK, epoch); + CheckNodeInfo(runtime, sender, 1024, TStatus::OK); + + WaitForEpochUpdate(runtime, sender); + CheckNodeInfo(runtime, sender, 1024, TStatus::OK); + + // Wait until node's lease expires + WaitForEpochUpdate(runtime, sender); + WaitForEpochUpdate(runtime, sender); + WaitForEpochUpdate(runtime, sender); + WaitForEpochUpdate(runtime, sender); + epoch = GetEpoch(runtime, sender); + + CheckNodeInfo(runtime, sender, 1024, TStatus::WRONG_REQUEST); + + // Register node 1088. + CheckRegistration(runtime, sender, "host2", 1001, "host2.yandex.net", "1.2.3.5", + 1, 2, 3, 5, TStatus::OK, 1088, epoch.GetNextEnd()); + } } Y_UNIT_TEST_SUITE(TDynamicNameserverTest) { |