Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #50334 to 23.4: Fix crash when Pool::Entry::disconnect() is called #51048

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 3 additions & 10 deletions src/Common/mysqlxx/Pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}
Expand Down