Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Client/MultiplexedConnections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ void MultiplexedConnections::sendIgnoredPartUUIDs(const std::vector<UUID> & uuid
void MultiplexedConnections::sendClusterFunctionReadTaskResponse(const ClusterFunctionReadTaskResponse & response)
{
std::lock_guard lock(cancel_mutex);
if (cancelled)
if (cancelled || !current_connection || !current_connection->isConnected())
return;
current_connection->sendClusterFunctionReadTaskResponse(response);
}
Expand All @@ -241,7 +241,7 @@ void MultiplexedConnections::sendClusterFunctionReadTaskResponse(const ClusterFu
void MultiplexedConnections::sendMergeTreeReadTaskResponse(const ParallelReadResponse & response)
{
std::lock_guard lock(cancel_mutex);
if (cancelled)
if (cancelled || !current_connection || !current_connection->isConnected())
return;
current_connection->sendMergeTreeReadTaskResponse(response);
}
Expand Down Expand Up @@ -527,9 +527,12 @@ MultiplexedConnections::ReplicaState & MultiplexedConnections::getReplicaForRead

void MultiplexedConnections::invalidateReplica(ReplicaState & state)
{
Connection * old_connection = state.connection;
state.connection = nullptr;
state.pool_entry = IConnectionPool::Entry();
--active_connection_count;
if (current_connection == old_connection)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it Ok that we don't acquire cancel_mutex here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, invalidateReplica is called under that mutex already, like in MultiplexedConnections::disconnect https://github.com/Altinity/ClickHouse/blob/antalya/src/Client/MultiplexedConnections.cpp#L239

current_connection = nullptr;
}

void MultiplexedConnections::setAsyncCallback(AsyncCallback async_callback)
Expand Down
Loading