Skip to content

Commit 274fd11

Browse files
measthamMichael Eastham
authored andcommitted
Fix race condition where destroying a closed connection can close a different connection
1 parent ae670ba commit 274fd11

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Contributors
22

33
4+
45

56
To see the list of authors who created the source code of ClickHouse, published and distributed by ClickHouse, Inc. as the owner,
67
run "SELECT * FROM system.contributors;" query on any ClickHouse server.

programs/local/LocalChdb.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,12 @@ connection_wrapper::~connection_wrapper()
285285

286286
void connection_wrapper::close()
287287
{
288-
py::gil_scoped_release release;
289-
close_conn(conn);
288+
{
289+
py::gil_scoped_release release;
290+
close_conn(conn);
291+
}
292+
// Ensure that if a new connection is created before this object is destroyed that we don't try to close it.
293+
conn = nullptr;
290294
}
291295

292296
cursor_wrapper * connection_wrapper::cursor()

0 commit comments

Comments
 (0)