Skip to content

Commit 2e5d3c5

Browse files
authored
Merge 02f4ddf into 8edc4ee
2 parents 8edc4ee + 02f4ddf commit 2e5d3c5

File tree

11 files changed

+43
-26
lines changed

11 files changed

+43
-26
lines changed

ydb/core/base/hive.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,9 @@ namespace NKikimr {
712712
{
713713
TEvLockTabletExecutionLost() = default;
714714

715-
explicit TEvLockTabletExecutionLost(ui64 tabletId) {
715+
explicit TEvLockTabletExecutionLost(ui64 tabletId, NKikimrHive::ELockLostReason reason) {
716716
Record.SetTabletID(tabletId);
717+
Record.SetReason(reason);
717718
}
718719
};
719720

ydb/core/mind/hive/hive_events.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "hive.h"
66
#include "tablet_info.h"
77
#include "node_info.h"
8+
#include "leader_tablet_info.h"
89

910
namespace NKikimr {
1011
namespace NHive {
@@ -71,12 +72,14 @@ struct TEvPrivate {
7172
struct TEvUnlockTabletReconnectTimeout : TEventLocal<TEvUnlockTabletReconnectTimeout, EvUnlockTabletReconnectTimeout> {
7273
ui64 TabletId;
7374
ui64 SeqNo;
75+
NKikimrHive::ELockLostReason Reason;
7476

7577
TEvUnlockTabletReconnectTimeout() = default;
7678

77-
explicit TEvUnlockTabletReconnectTimeout(ui64 tabletId, ui64 seqNo)
78-
: TabletId(tabletId)
79-
, SeqNo(seqNo)
79+
explicit TEvUnlockTabletReconnectTimeout(const TLeaderTabletInfo& tablet, NKikimrHive::ELockLostReason reason)
80+
: TabletId(tablet.Id)
81+
, SeqNo(tablet.PendingUnlockSeqNo)
82+
, Reason(reason)
8083
{}
8184
};
8285

ydb/core/mind/hive/hive_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class THive : public TActor<THive>, public TTabletExecutedFlat, public THiveShar
286286
ITransaction* CreateReassignGroupsOnDecommit(ui32 groupId, std::unique_ptr<IEventHandle> reply);
287287
ITransaction* CreateLockTabletExecution(const NKikimrHive::TEvLockTabletExecution& rec, const TActorId& sender, const ui64 cookie);
288288
ITransaction* CreateUnlockTabletExecution(const NKikimrHive::TEvUnlockTabletExecution& rec, const TActorId& sender, const ui64 cookie);
289-
ITransaction* CreateUnlockTabletExecution(ui64 tabletId, ui64 seqNo);
289+
ITransaction* CreateUnlockTabletExecution(ui64 tabletId, ui64 seqNo, NKikimrHive::ELockLostReason reason);
290290
ITransaction* CreateRequestTabletSequence(TEvHive::TEvRequestTabletIdSequence::TPtr event);
291291
ITransaction* CreateResponseTabletSequence(TEvHive::TEvResponseTabletIdSequence::TPtr event);
292292
ITransaction* CreateDisconnectNode(THolder<TEvInterconnect::TEvNodeDisconnected> event);
@@ -995,7 +995,7 @@ TTabletInfo* FindTabletEvenInDeleting(TTabletId tabletId, TFollowerId followerId
995995
void DeleteTabletWithoutStorage(TLeaderTabletInfo* tablet);
996996
void DeleteTabletWithoutStorage(TLeaderTabletInfo* tablet, TSideEffects& sideEffects);
997997
TInstant GetAllowedBootingTime();
998-
void ScheduleUnlockTabletExecution(TNodeInfo& node);
998+
void ScheduleUnlockTabletExecution(TNodeInfo& node, NKikimrHive::ELockLostReason reason);
999999
TString DebugDomainsActiveNodes() const;
10001000
TResourceNormalizedValues GetStDevResourceValues() const;
10011001
bool IsTabletMoveExpedient(const TTabletInfo& tablet, const TNodeInfo& node) const;

ydb/core/mind/hive/hive_ut.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5845,12 +5845,13 @@ Y_UNIT_TEST_SUITE(THiveTest) {
58455845
UNIT_ASSERT_VALUES_EQUAL(result->Record.GetStatus(), expectedStatus);
58465846
}
58475847

5848-
void VerifyLockTabletExecutionLost(TTestActorRuntime& runtime, ui64 tabletId, const TActorId& owner) {
5848+
void VerifyLockTabletExecutionLost(TTestActorRuntime& runtime, ui64 tabletId, const TActorId& owner, NKikimrHive::ELockLostReason reason) {
58495849
TAutoPtr<IEventHandle> handle;
58505850
auto result = runtime.GrabEdgeEventRethrow<TEvHive::TEvLockTabletExecutionLost>(handle);
58515851
UNIT_ASSERT(result);
58525852
UNIT_ASSERT_VALUES_EQUAL(handle->GetRecipientRewrite(), owner);
58535853
UNIT_ASSERT_VALUES_EQUAL(result->Record.GetTabletID(), tabletId);
5854+
UNIT_ASSERT_VALUES_EQUAL(static_cast<i32>(result->Record.GetReason()), static_cast<i32>(reason));
58545855
}
58555856

58565857
Y_UNIT_TEST(TestLockTabletExecution) {
@@ -5924,7 +5925,7 @@ Y_UNIT_TEST_SUITE(THiveTest) {
59245925
WaitForTabletIsUp(runtime, tabletId, 0);
59255926

59265927
// Hive should try to notify owner on unlocking
5927-
VerifyLockTabletExecutionLost(runtime, tabletId, owner);
5928+
VerifyLockTabletExecutionLost(runtime, tabletId, owner, NKikimrHive::LOCK_LOST_REASON_NODE_DISCONNECTED);
59285929
}
59295930

59305931
Y_UNIT_TEST(TestLockTabletExecutionRebootTimeout) {
@@ -5953,7 +5954,7 @@ Y_UNIT_TEST_SUITE(THiveTest) {
59535954
WaitForTabletIsUp(runtime, tabletId, 0);
59545955

59555956
// Hive should try to notify owner on unlocking
5956-
VerifyLockTabletExecutionLost(runtime, tabletId, owner);
5957+
VerifyLockTabletExecutionLost(runtime, tabletId, owner, NKikimrHive::LOCK_LOST_REASON_HIVE_RESTART);
59575958
}
59585959

59595960
Y_UNIT_TEST(TestLockTabletExecutionDelete) {
@@ -5989,7 +5990,7 @@ Y_UNIT_TEST_SUITE(THiveTest) {
59895990
}
59905991

59915992
// Hive should try to notify owner on unlocking
5992-
VerifyLockTabletExecutionLost(runtime, tabletId, owner);
5993+
VerifyLockTabletExecutionLost(runtime, tabletId, owner, NKikimrHive::LOCK_LOST_REASON_TABLET_DELETED);
59935994
}
59945995

59955996
Y_UNIT_TEST(TestLockTabletExecutionDeleteReboot) {
@@ -6030,7 +6031,7 @@ Y_UNIT_TEST_SUITE(THiveTest) {
60306031
RebootTablet(runtime, hiveTablet, runtime.AllocateEdgeActor(0));
60316032

60326033
// Hive should try to notify owner on unlocking
6033-
VerifyLockTabletExecutionLost(runtime, tabletId, owner);
6034+
VerifyLockTabletExecutionLost(runtime, tabletId, owner, NKikimrHive::LOCK_LOST_REASON_TABLET_DELETED);
60346035
}
60356036

60366037
void MakeSureTabletStaysDown(TTestActorRuntime& runtime, ui64 tabletId, const TDuration& timeout) {
@@ -6140,7 +6141,7 @@ Y_UNIT_TEST_SUITE(THiveTest) {
61406141
runtime.Send(new IEventHandle(proxy, disconnecter, new TEvInterconnect::TEvDisconnect()), 0);
61416142

61426143
// wait for the lost lock notification
6143-
VerifyLockTabletExecutionLost(runtime, tabletId, owner);
6144+
VerifyLockTabletExecutionLost(runtime, tabletId, owner, NKikimrHive::LOCK_LOST_REASON_NODE_DISCONNECTED);
61446145

61456146
// lock reconnect should fail
61466147
SendLockTabletExecution(runtime, hiveTablet, tabletId, 1, NKikimrProto::ERROR, owner, 500, true);
@@ -6210,7 +6211,7 @@ Y_UNIT_TEST_SUITE(THiveTest) {
62106211
WaitForTabletIsUp(runtime, tabletId, 0);
62116212

62126213
// Hive should try to notify owner on unlocking
6213-
VerifyLockTabletExecutionLost(runtime, tabletId, owner);
6214+
VerifyLockTabletExecutionLost(runtime, tabletId, owner, NKikimrHive::LOCK_LOST_REASON_NO);
62146215
}
62156216

62166217
Y_UNIT_TEST(TestLockTabletExecutionStealLock) {
@@ -6236,7 +6237,7 @@ Y_UNIT_TEST_SUITE(THiveTest) {
62366237
SendLockTabletExecution(runtime, hiveTablet, tabletId, 1, NKikimrProto::OK, owner2);
62376238

62386239
// Hive should notify the old owner on unlocking
6239-
VerifyLockTabletExecutionLost(runtime, tabletId, owner);
6240+
VerifyLockTabletExecutionLost(runtime, tabletId, owner, NKikimrHive::LOCK_LOST_REASON_NEW_LOCK);
62406241
}
62416242

62426243
Y_UNIT_TEST(TestLockTabletExecutionLocalGone) {

ydb/core/mind/hive/tx__delete_tablet_result.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class TTxDeleteTabletResult : public TTransactionBase<THive> {
5252
TActorId unlockedFromActor = tablet->ClearLockedToActor();
5353
if (unlockedFromActor) {
5454
// Notify lock owner that lock has been lost
55-
SideEffects.Send(unlockedFromActor, new TEvHive::TEvLockTabletExecutionLost(TabletId));
55+
SideEffects.Send(unlockedFromActor, new TEvHive::TEvLockTabletExecutionLost(TabletId, NKikimrHive::LOCK_LOST_REASON_TABLET_DELETED));
5656
}
5757
Self->PendingCreateTablets.erase({tablet->Owner.first, tablet->Owner.second});
5858
Self->DeleteTablet(tablet->Id);

ydb/core/mind/hive/tx__disconnect_node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class TTxDisconnectNode : public TTransactionBase<THive> {
2020
BLOG_D("THive::TTxDisconnectNode()::Execute");
2121
TNodeInfo* node = Self->FindNode(Event->NodeId);
2222
if (node != nullptr) {
23-
Self->ScheduleUnlockTabletExecution(*node);
23+
Self->ScheduleUnlockTabletExecution(*node, NKikimrHive::LOCK_LOST_REASON_NODE_DISCONNECTED);
2424
if (node->BecomeDisconnecting()) {
2525
THolder<TEvPrivate::TEvProcessDisconnectNode> event = MakeHolder<TEvPrivate::TEvProcessDisconnectNode>();
2626
event->NodeId = node->Id;

ydb/core/mind/hive/tx__load_everything.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ class TTxLoadEverything : public TTransactionBase<THive> {
857857
ctx.Send(Self->SelfId(), new TEvPrivate::TEvBootTablets());
858858

859859
for (auto it = Self->Nodes.begin(); it != Self->Nodes.end(); ++it) {
860-
Self->ScheduleUnlockTabletExecution(it->second);
860+
Self->ScheduleUnlockTabletExecution(it->second, NKikimrHive::LOCK_LOST_REASON_HIVE_RESTART);
861861
}
862862
}
863863
};

ydb/core/mind/hive/tx__lock_tablet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class TTxLockTabletExecution : public TTransactionBase<THive> {
8686
ui32 flags = 0;
8787
if (PreviousOwner && PreviousOwner != OwnerActor) {
8888
// Notify previous owner that its lock ownership has been lost
89-
SideEffects.Send(PreviousOwner, new TEvHive::TEvLockTabletExecutionLost(TabletId));
89+
SideEffects.Send(PreviousOwner, new TEvHive::TEvLockTabletExecutionLost(TabletId, NKikimrHive::LOCK_LOST_REASON_NEW_LOCK));
9090
}
9191

9292
if (tablet->IsLockedToActor()) {

ydb/core/mind/hive/tx__release_tablets.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class TTxReleaseTablets : public TTransactionBase<THive> {
8282
SideEffects.Complete(ctx);
8383
for (const auto& unlockedFromActor : UnlockedFromActor) {
8484
// Notify lock owner that lock has been lost
85-
ctx.Send(unlockedFromActor.second, new TEvHive::TEvLockTabletExecutionLost(unlockedFromActor.first));
85+
ctx.Send(unlockedFromActor.second, new TEvHive::TEvLockTabletExecutionLost(unlockedFromActor.first, NKikimrHive::LOCK_LOST_REASON_TABLET_RELEASED));
8686
}
8787
ctx.Send(Request->Sender, Response.Release());
8888
if (NeedToProcessPendingOperations) {

ydb/core/mind/hive/tx__unlock_tablet.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class TTxUnlockTabletExecution : public TTransactionBase<THive> {
88
const ui64 TabletId;
99
const TActorId OwnerActor;
1010
const ui64 SeqNo;
11+
const NKikimrHive::ELockLostReason Reason = NKikimrHive::LOCK_LOST_REASON_NO;
1112

1213
const TActorId Sender;
1314
const ui64 Cookie;
@@ -29,10 +30,11 @@ class TTxUnlockTabletExecution : public TTransactionBase<THive> {
2930

3031
TTxType GetTxType() const override { return NHive::TXTYPE_UNLOCK_TABLET_EXECUTION; }
3132

32-
TTxUnlockTabletExecution(ui64 tabletId, ui64 seqNo, THive* hive)
33+
TTxUnlockTabletExecution(ui64 tabletId, ui64 seqNo, NKikimrHive::ELockLostReason reason, THive* hive)
3334
: TBase(hive)
3435
, TabletId(tabletId)
3536
, SeqNo(seqNo)
37+
, Reason(reason)
3638
, Cookie(0)
3739
{}
3840

@@ -70,7 +72,7 @@ class TTxUnlockTabletExecution : public TTransactionBase<THive> {
7072

7173
if (PreviousOwner) {
7274
// Notify previous owner that its lock ownership has been lost
73-
SideEffects.Send(PreviousOwner, new TEvHive::TEvLockTabletExecutionLost(TabletId));
75+
SideEffects.Send(PreviousOwner, new TEvHive::TEvLockTabletExecutionLost(TabletId, Reason));
7476
}
7577

7678
if (!tablet->IsLockedToActor()) {
@@ -100,19 +102,19 @@ ITransaction* THive::CreateUnlockTabletExecution(const NKikimrHive::TEvUnlockTab
100102
return new TTxUnlockTabletExecution(rec, sender, cookie, this);
101103
}
102104

103-
ITransaction* THive::CreateUnlockTabletExecution(ui64 tabletId, ui64 seqNo) {
104-
return new TTxUnlockTabletExecution(tabletId, seqNo, this);
105+
ITransaction* THive::CreateUnlockTabletExecution(ui64 tabletId, ui64 seqNo, NKikimrHive::ELockLostReason reason) {
106+
return new TTxUnlockTabletExecution(tabletId, seqNo, reason, this);
105107
}
106108

107-
void THive::ScheduleUnlockTabletExecution(TNodeInfo& node) {
109+
void THive::ScheduleUnlockTabletExecution(TNodeInfo& node, NKikimrHive::ELockLostReason reason) {
108110
// Unlock tablets that have been locked by this node
109111
for (TLeaderTabletInfo* tablet : node.LockedTablets) {
110112
Y_ABORT_UNLESS(FindTabletEvenInDeleting(tablet->Id) == tablet);
111113
Y_ABORT_UNLESS(tablet->LockedToActor.NodeId() == node.Id);
112114
if (tablet->PendingUnlockSeqNo == 0) {
113115
tablet->PendingUnlockSeqNo = NextTabletUnlockSeqNo++;
114116
Y_ABORT_UNLESS(tablet->PendingUnlockSeqNo != 0);
115-
auto event = new TEvPrivate::TEvUnlockTabletReconnectTimeout(tablet->Id, tablet->PendingUnlockSeqNo);
117+
auto event = new TEvPrivate::TEvUnlockTabletReconnectTimeout(*tablet, reason);
116118
if (tablet->LockedReconnectTimeout) {
117119
Schedule(tablet->LockedReconnectTimeout, event);
118120
} else {
@@ -141,7 +143,7 @@ void THive::Handle(TEvPrivate::TEvUnlockTabletReconnectTimeout::TPtr& ev) {
141143
// - reconnect timeout (execute, failure)
142144
// tablet is not unlocked, because logically lock/reconnect
143145
// transaction was scheduled before the timeout really happened.
144-
Execute(CreateUnlockTabletExecution(tabletId, seqNo));
146+
Execute(CreateUnlockTabletExecution(tabletId, seqNo, ev->Get()->Reason));
145147
}
146148
}
147149

0 commit comments

Comments
 (0)