Skip to content

Commit 903c6b6

Browse files
authored
Fix possible race with NodeDisconnected and incoming messages (#11024)
1 parent a48e874 commit 903c6b6

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

ydb/library/actors/interconnect/interconnect_tcp_input_session.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ namespace NActors {
147147
STATEFN(TInputSessionTCP::WorkingState) {
148148
std::unique_ptr<IEventBase> termEv;
149149

150+
if (Context->Terminated) {
151+
return PassAway();
152+
}
153+
150154
try {
151155
WorkingStateImpl(ev);
152156
} catch (const TExReestablishConnection& ex) {

ydb/library/actors/interconnect/interconnect_tcp_session.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ namespace NActors {
8484
IActor::InvokeOtherActor(*Proxy, &TInterconnectProxyTCP::UnregisterSession, this);
8585
ShutdownSocket(std::move(reason));
8686

87+
ReceiveContext->Terminated = true; // prevent further message generation by receiving actor
8788
for (const auto& kv : Subscribers) {
8889
Send(kv.first, new TEvInterconnect::TEvNodeDisconnected(Proxy->PeerNodeId), 0, kv.second);
8990
}

ydb/library/actors/interconnect/interconnect_tcp_session.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ namespace NActors {
100100
};
101101

102102
struct TReceiveContext: public TAtomicRefCount<TReceiveContext> {
103-
/* All invokations to these fields should be thread-safe */
104-
105103
ui64 ControlPacketSendTimer = 0;
106104
ui64 ControlPacketId = 0;
107105

@@ -153,6 +151,7 @@ namespace NActors {
153151
std::array<TPerChannelContext, 16> ChannelArray;
154152
std::unordered_map<ui16, TPerChannelContext> ChannelMap;
155153
ui64 LastProcessedSerial = 0;
154+
bool Terminated = false;
156155

157156
TReceiveContext() {
158157
GetTimeFast(&StartTime);

0 commit comments

Comments
 (0)