mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Merge pull request #50334 from valbok/pool-mem-leak
Fix crash when Pool::Entry::disconnect() is called
This commit is contained in:
commit
9ff4e6d6a3
@ -40,14 +40,10 @@ void Pool::Entry::decrementRefCount()
|
||||
{
|
||||
/// We were the last user of this thread, deinitialize it
|
||||
mysql_thread_end();
|
||||
}
|
||||
else if (data->removed_from_pool)
|
||||
{
|
||||
/// data->ref_count == 0 in case we removed connection from pool (see Pool::removeConnection).
|
||||
chassert(ref_count == 0);
|
||||
/// In Pool::Entry::disconnect() we remove connection from the list of pool's connections.
|
||||
/// So now we must deallocate the memory.
|
||||
::delete data;
|
||||
if (data->removed_from_pool)
|
||||
::delete data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,11 +230,8 @@ void Pool::removeConnection(Connection* connection)
|
||||
std::lock_guard lock(mutex);
|
||||
if (connection)
|
||||
{
|
||||
if (connection->ref_count > 0)
|
||||
{
|
||||
if (!connection->removed_from_pool)
|
||||
connection->conn.disconnect();
|
||||
connection->ref_count = 0;
|
||||
}
|
||||
connections.remove(connection);
|
||||
connection->removed_from_pool = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user