Open
Description
Bug Report
YDB Python SDK version:
3.21.2 (?)
Environment
Python 3.12.9
10 node cluster
Current behavior:
When invoking pool.stop()
after queries with failures (in my case it is BATCH UPDATE
)
2025-06-05 17:55:33,565 - DEBUG - ydb.connection - _prepare_call: RpcState(DeleteSession, 03b64361-8de0-40c7-9c12-004804a25dbe, ***:4616): creating call state
2025-06-05 17:55:33,566 - DEBUG - ydb.connection - _log_request: RpcState(DeleteSession, 03b64361-8de0-40c7-9c12-004804a25dbe, ***:4616): request = { session_id: "ydb://session/3?node_id=4&id=ZWY1NzYwNmUtNGRkYjZjZTEtNGM0ZDBlMi1mMjNmNDU2Mg==" }
2025-06-05 17:55:33,566 - DEBUG - ydb.connection - _log_response: RpcState(DeleteSession, 03b64361-8de0-40c7-9c12-004804a25dbe, ***:4616): response = { status: SUCCESS }
2025-06-05 17:55:33,567 - DEBUG - ydb.connection - _prepare_call: RpcState(DeleteSession, 4d3caea5-be7e-49db-b071-8e3b2a5e0f9d, ***:11724): creating call state
2025-06-05 17:55:33,567 - DEBUG - ydb.connection - _log_request: RpcState(DeleteSession, 4d3caea5-be7e-49db-b071-8e3b2a5e0f9d, ***:11724): request = { session_id: "ydb://session/3?node_id=7&id=ZDk4YzA0NDktNTc4YmNhMjktYmE0NGQ3MDUtYWU1MzBjOGY=" }
2025-06-05 17:55:33,567 - DEBUG - ydb.connection - _log_response: RpcState(DeleteSession, 4d3caea5-be7e-49db-b071-8e3b2a5e0f9d, ***:11724): response = { status: SUCCESS }
2025-06-05 17:55:33,568 - DEBUG - ydb.connection - _prepare_call: RpcState(DeleteSession, 268b8739-3c21-4be1-9149-364414010086, ***:12324): creating call state
2025-06-05 17:55:33,568 - DEBUG - ydb.connection - _log_request: RpcState(DeleteSession, 268b8739-3c21-4be1-9149-364414010086, ***:12324): request = { session_id: "ydb://session/3?node_id=7&id=MTE4Y2M2OGYtZDJiYmIxOTQtNjM4MTdkMzMtMTJlZWM3MTg=" }
2025-06-05 17:55:33,569 - DEBUG - ydb.connection - _log_response: RpcState(DeleteSession, 268b8739-3c21-4be1-9149-364414010086, ***:12324): response = { status: SUCCESS }
2025-06-05 17:55:33,569 - DEBUG - ydb.connection - _prepare_call: RpcState(DeleteSession, 5ee4cd66-b465-431d-8832-f39565cabafa, ***:4616): creating call state
2025-06-05 17:55:33,569 - DEBUG - ydb.connection - _log_request: RpcState(DeleteSession, 5ee4cd66-b465-431d-8832-f39565cabafa, ***:4616): request = { }
2025-06-05 17:55:33,570 - DEBUG - ydb.connection - _log_response: RpcState(DeleteSession, 5ee4cd66-b465-431d-8832-f39565cabafa, ***:4616): response = { status: BAD_REQUEST issues { message: "Empty session id" severity: 1 } }
Expected behavior:
Expecting QueriySessionPool
to close all created sessions
Steps to reproduce:
Using QuerySessionPool(200) to generate some failing queries ~ 300 (single process, multiple threads)
Wait for the queries to finish processing
pool.stop()
Related code:
The problem is consistent after approx 2 minutes of sessionPool usage, so increase iteration number as needed
def test_pool(self):
s_pool = ydb.QuerySessionPool(self.driver, size=200)
conn = self.ydb_queues[0]
pool = ThreadPoolExecutor(200)
def work():
try:
blob = next(conn.blobs_iter)
res = s_pool.execute_with_retries("BATCH UPDATE `{}` SET value = $value;".format(
conn.table_name), retry_settings=ydb.RetrySettings(max_retries=0),
parameters={"$value": blob},
settings=ydb.BaseRequestSettings().with_operation_timeout(19).with_timeout(20))
print(res)
except Exception as e:
print(e)
for i in range(100):
if len(self.worker_exception) == 0:
self.pool_semaphore.acquire()
pool.submit(self.wrapper, work)
else:
assert False, f"Worker exceptions {self.worker_exception}"
pool.shutdown(wait=True)
s_pool.stop()