Skip to content

Commit 411f8ba

Browse files
qyryqGazizonoki
authored andcommitted
Moved "Increment ConnectionGeneration in ConnectToPreferredPartitionLocation" commit from ydb repo
1 parent 42c7f75 commit 411f8ba

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/client/topic/impl/write_session_impl.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,23 +107,22 @@ void TWriteSessionImpl::Start(const TDuration& delay) {
107107
EventsQueue = std::make_shared<TWriteSessionEventsQueue>(Settings);
108108
}
109109

110-
++ConnectionAttemptsDone;
111110
if (!Started) {
112-
{
113-
std::lock_guard guard(Lock);
111+
with_lock(Lock) {
114112
HandleWakeUpImpl();
115113
}
116114
InitWriter();
117115
}
118-
Started = true;
119-
120-
if (Settings.DirectWriteToPartition_ && (Settings.PartitionId_.has_value() || DirectWriteToPartitionId.has_value())) {
121-
std::lock_guard guard(Lock);
122-
PreferredPartitionLocation = {};
123-
return ConnectToPreferredPartitionLocation(delay);
124-
} else {
125-
return Connect(delay);
116+
with_lock(Lock) {
117+
++ConnectionAttemptsDone;
118+
Started = true;
119+
if (Settings.DirectWriteToPartition_ && (Settings.PartitionId_.has_value() || DirectWriteToPartitionId.has_value())) {
120+
PreferredPartitionLocation = {};
121+
ConnectToPreferredPartitionLocation(delay);
122+
return;
123+
}
126124
}
125+
Connect(delay);
127126
}
128127

129128
// Returns true if we need to switch to another DirectWriteToPartitionId.
@@ -243,6 +242,8 @@ void TWriteSessionImpl::ConnectToPreferredPartitionLocation(const TDuration& del
243242
return;
244243
}
245244

245+
++ConnectionGeneration;
246+
246247
prevDescribePartitionContext = std::exchange(DescribePartitionContext, describePartitionContext);
247248
Y_ASSERT(DescribePartitionContext);
248249
Cancel(prevDescribePartitionContext);

0 commit comments

Comments
 (0)