diff options
| author | vporyadke <[email protected]> | 2026-07-10 17:01:24 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-07-10 16:01:24 +0200 |
| commit | 4e2800b11544e1e45154a4e2af14499eb46f9652 (patch) | |
| tree | 7d066928cc005c55d7294431d8bb4bd45dd8b9b9 | |
| parent | c80133c2ae13755f8f0e1e0bc2cb8402811787df (diff) | |
use fast tablet move logic for other restarts too (#46044)
| -rw-r--r-- | ydb/core/mind/hive/hive_impl.cpp | 2 | ||||
| -rw-r--r-- | ydb/core/mind/hive/hive_impl.h | 1 | ||||
| -rw-r--r-- | ydb/core/mind/hive/hive_ut.cpp | 50 | ||||
| -rw-r--r-- | ydb/core/mind/hive/monitoring.cpp | 2 | ||||
| -rw-r--r-- | ydb/core/mind/hive/tx__block_storage_result.cpp | 2 | ||||
| -rw-r--r-- | ydb/core/mind/hive/tx__restart_tablet.cpp | 10 |
6 files changed, 42 insertions, 25 deletions
diff --git a/ydb/core/mind/hive/hive_impl.cpp b/ydb/core/mind/hive/hive_impl.cpp index 511a191321c..de25109ab60 100644 --- a/ydb/core/mind/hive/hive_impl.cpp +++ b/ydb/core/mind/hive/hive_impl.cpp @@ -929,7 +929,7 @@ void THive::Handle(TEvPrivate::TEvKickTablet::TPtr &ev) { Execute(CreateRestartTablet(tabletId)); } } else { - Execute(CreateRestartTablet(tabletId)); + Execute(CreateForceRestartTablet(tabletId)); } } diff --git a/ydb/core/mind/hive/hive_impl.h b/ydb/core/mind/hive/hive_impl.h index ce4ba3d7016..8d7bab198d3 100644 --- a/ydb/core/mind/hive/hive_impl.h +++ b/ydb/core/mind/hive/hive_impl.h @@ -268,6 +268,7 @@ protected: ITransaction* CreateBlockStorageResult(TEvTabletBase::TEvBlockBlobStorageResult::TPtr& ev); ITransaction* CreateRestartTablet(TFullTabletId tabletId); ITransaction* CreateRestartTablet(TFullTabletId tabletId, TNodeId preferredNodeId); + ITransaction* CreateForceRestartTablet(TFullTabletId tabletId); ITransaction* CreateInitScheme(); ITransaction* CreateAdoptTablet(NKikimrHive::TEvAdoptTablet &rec, const TActorId &sender, const ui64 cookie); ITransaction* CreateCreateTablet(NKikimrHive::TEvCreateTablet rec, const TActorId& sender, const ui64 cookie); diff --git a/ydb/core/mind/hive/hive_ut.cpp b/ydb/core/mind/hive/hive_ut.cpp index d598b3a94f8..c521dfa9fd2 100644 --- a/ydb/core/mind/hive/hive_ut.cpp +++ b/ydb/core/mind/hive/hive_ut.cpp @@ -2853,6 +2853,32 @@ Y_UNIT_TEST_SUITE(THiveTest) { WaitForTabletIsUp(runtime, tabletId, 0, &pipeConfig); } + Y_UNIT_TEST(TestNodeDisconnectedButAlive) { + TTestBasicRuntime runtime(1, false); + Setup(runtime, true); + TActorId sender = runtime.AllocateEdgeActor(); + const ui64 hiveTablet = MakeDefaultHiveID(); + const ui64 testerTablet = MakeTabletID(false, 1); + CreateTestBootstrapper(runtime, CreateTestTabletInfo(hiveTablet, TTabletTypes::Hive), &CreateDefaultHive); + + TTabletTypes::EType tabletType = TTabletTypes::Dummy; + THolder<TEvHive::TEvCreateTablet> ev(new TEvHive::TEvCreateTablet(testerTablet, 100500, tabletType, BINDED_CHANNELS)); + ui64 tabletId = SendCreateTestTablet(runtime, hiveTablet, testerTablet, std::move(ev), 0, true); + + NTabletPipe::TClientConfig pipeConfig; + pipeConfig.RetryPolicy = NTabletPipe::TClientRetryPolicy::WithRetries(); + pipeConfig.ForceLocal = true; + + WaitForTabletIsUp(runtime, tabletId, 0, &pipeConfig); + + // Simulating a case where IC between hive and node breaks + // Hive has nowhere to start the tablet anyway, so it must not kill it + TBlockEvents<TEvLocal::TEvPing> blockReconnect(runtime); + runtime.SendToPipe(hiveTablet, sender, new TEvInterconnect::TEvNodeDisconnected(runtime.GetNodeId(0))); + runtime.WaitFor("process disconnect", [&] { return !blockReconnect.empty(); }); + MakeSureTabletIsUp(runtime, tabletId, 0, &pipeConfig); + } + Y_UNIT_TEST(TestLocalReplacement) { TTestBasicRuntime runtime(2, false); Setup(runtime, true); @@ -7852,11 +7878,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { // restart to kick tablet SendKillLocal(runtime, 0); - { - TDispatchOptions options; - options.FinalEvents.emplace_back(TEvLocal::EvStopTablet); - runtime.DispatchEvents(options); - } + MakeSureTabletIsDown(runtime, dummyTabletId, 0); CreateLocal(runtime, 0); MakeSureTabletIsUp(runtime, dummyTabletId, 0); @@ -7877,11 +7899,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { // restart to kick tablet SendKillLocal(runtime, 1); - { - TDispatchOptions options; - options.FinalEvents.emplace_back(TEvLocal::EvStopTablet); - runtime.DispatchEvents(options); - } + MakeSureTabletIsDown(runtime, dummyTabletId, 0); CreateLocalForTenant(runtime, 1, "/dc-1/tenant1"); MakeSureTabletIsUp(runtime, dummyTabletId, 0); @@ -7958,11 +7976,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { // restart to kick tablet SendKillLocal(runtime, 0); - { - TDispatchOptions options; - options.FinalEvents.emplace_back(TEvLocal::EvStopTablet); - runtime.DispatchEvents(options); - } + MakeSureTabletIsDown(runtime, dummyTabletId, 0); CreateLocal(runtime, 0); MakeSureTabletIsUp(runtime, dummyTabletId, 0); @@ -7983,11 +7997,7 @@ Y_UNIT_TEST_SUITE(THiveTest) { // restart to kick tablet SendKillLocal(runtime, 1); - { - TDispatchOptions options; - options.FinalEvents.emplace_back(TEvLocal::EvStopTablet); - runtime.DispatchEvents(options); - } + MakeSureTabletIsDown(runtime, dummyTabletId, 0); CreateLocalForTenant(runtime, 1, "/dc-1/tenant1"); MakeSureTabletIsUp(runtime, dummyTabletId, 0); diff --git a/ydb/core/mind/hive/monitoring.cpp b/ydb/core/mind/hive/monitoring.cpp index 7053c22df90..4a6a897c4a6 100644 --- a/ydb/core/mind/hive/monitoring.cpp +++ b/ydb/core/mind/hive/monitoring.cpp @@ -3109,7 +3109,7 @@ public: return true; } for (const auto& tablet : Self->Tablets) { - Self->Execute(Self->CreateRestartTablet(tablet.second.GetFullTabletId())); + Self->Execute(Self->CreateForceRestartTablet(tablet.second.GetFullTabletId())); } return true; } diff --git a/ydb/core/mind/hive/tx__block_storage_result.cpp b/ydb/core/mind/hive/tx__block_storage_result.cpp index aa20a3377fb..e5321a5241b 100644 --- a/ydb/core/mind/hive/tx__block_storage_result.cpp +++ b/ydb/core/mind/hive/tx__block_storage_result.cpp @@ -44,7 +44,7 @@ public: // Use best effort to kill currently running tablet SideEffects.Register(CreateTabletKiller(TabletId, /* nodeId */ 0, tablet->KnownGeneration)); } else { - Self->Execute(Self->CreateRestartTablet(tablet->GetFullTabletId())); + Self->Execute(Self->CreateForceRestartTablet(tablet->GetFullTabletId())); } } } else { diff --git a/ydb/core/mind/hive/tx__restart_tablet.cpp b/ydb/core/mind/hive/tx__restart_tablet.cpp index 2e5f44e12e7..d72a2a1954f 100644 --- a/ydb/core/mind/hive/tx__restart_tablet.cpp +++ b/ydb/core/mind/hive/tx__restart_tablet.cpp @@ -9,11 +9,13 @@ protected: TFullTabletId TabletId; TNodeId PreferredNodeId; TSideEffects SideEffects; + bool ForceStop = false; public: - TTxRestartTablet(TFullTabletId tabletId, THive *hive) + TTxRestartTablet(TFullTabletId tabletId, THive *hive, bool forceStop = false) : TBase(hive) , TabletId(tabletId) , PreferredNodeId(0) + , ForceStop(forceStop) {} TTxRestartTablet(TFullTabletId tabletId, TNodeId preferredNodeId, THive *hive) @@ -42,7 +44,7 @@ public: db.Table<Schema::TabletFollowerTablet>().Key(tablet->GetFullTabletId()).Update<Schema::TabletFollowerTablet::FollowerNode>(0); } } - tablet->InitiateStop(SideEffects, PreferredNodeId != 0); + tablet->InitiateStop(SideEffects, !ForceStop); } if (tablet->IsLeader() && tablet->AsLeader().ChannelProfileNewGroup.any()) { tablet->AsLeader().InitiateAssignTabletGroups(); @@ -70,5 +72,9 @@ ITransaction* THive::CreateRestartTablet(TFullTabletId tabletId, TNodeId preferr return new TTxRestartTablet(tabletId, preferredNodeId, this); } +ITransaction* THive::CreateForceRestartTablet(TFullTabletId tabletId) { + return new TTxRestartTablet(tabletId, this, true); +} + } // NHive } // NKikimr |
