Skip to content

bug: QuerySessionPool.close() tries to delete an empty session #671

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

Open
PavelEfarinov opened this issue Jun 5, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@PavelEfarinov
Copy link

PavelEfarinov commented Jun 5, 2025

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()
@PavelEfarinov PavelEfarinov added the bug Something isn't working label Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant