Skip to content

Commit c16fe48

Browse files
qyryqGazizonoki
authored andcommitted
Moved "ydb_topic: reuse client context in write session on reconnects" commit from ydb repo
1 parent e8eb447 commit c16fe48

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/client/topic/impl/write_session_impl.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -546,29 +546,29 @@ void TWriteSessionImpl::Connect(const TDuration& delay) {
546546
std::function<void(TPlainStatus&&, typename IProcessor::TPtr&&)> connectCallback;
547547
std::function<void(bool)> connectTimeoutCallback;
548548

549-
{
550-
std::lock_guard guard(Lock);
549+
with_lock(Lock) {
551550
if (Aborting) {
552551
return;
553552
}
554553

555554
LOG_LAZY(DbDriverState->Log, TLOG_INFO, LogPrefix() << "Start write session. Will connect to nodeId: " << PreferredPartitionLocation.Endpoint.NodeId);
556555

557556
++ConnectionGeneration;
558-
auto subclient = Client;
559-
connectionFactory = subclient->CreateWriteSessionConnectionProcessorFactory();
560-
auto clientContext = subclient->CreateContext();
561-
ConnectionFactory = connectionFactory;
562-
563-
ClientContext = std::move(clientContext);
564-
ServerMessage = std::make_shared<TServerMessage>();
565557

566558
if (!ClientContext) {
567-
AbortImpl();
568-
// Grpc and WriteSession is closing right now.
569-
return;
559+
ClientContext = Client->CreateContext();
560+
if (!ClientContext) {
561+
AbortImpl();
562+
// Grpc and WriteSession is closing right now.
563+
return;
564+
}
570565
}
571566

567+
ServerMessage = std::make_shared<TServerMessage>();
568+
569+
connectionFactory = Client->CreateWriteSessionConnectionProcessorFactory();
570+
ConnectionFactory = connectionFactory;
571+
572572
connectContext = ClientContext->CreateContext();
573573
if (delay)
574574
connectDelayContext = ClientContext->CreateContext();

0 commit comments

Comments
 (0)