Skip to content

bug: Task exception was never retrieved (BadSession: Session not found) #569

Closed

Description

@vladkolotvin

Bug Report

YDB Python SDK version:

3.18.17

Environment

python 3.12.16
linux
x86_64

Current behavior:

Task exception was never retrieved
future: <Task finished name='Task-25851' coro=<SessionPool._send_keep_alive() done, defined at /usr/local/lib/python3.12/site-packages/ydb/aio/table.py:682> exception=BadSession('message: "Session not found." severity: 1 (server_code: 400100)')>
Traceback (most recent call last):
  File \"/usr/local/lib/python3.12/site-packages/ydb/aio/table.py\", line 688, in _send_keep_alive
    await session.keep_alive(self._req_settings)
  File \"/usr/local/lib/python3.12/site-packages/ydb/aio/table.py\", line 61, in keep_alive
    return await super().keep_alive(settings)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/local/lib/python3.12/site-packages/ydb/aio/pool.py\", line 254, in __call__
    return await connection(
           ^^^^^^^^^^^^^^^^^
  File \"/usr/local/lib/python3.12/site-packages/ydb/aio/connection.py\", line 195, in __call__
    return response if wrap_result is None else wrap_result(rpc_state, response, *wrap_args)
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/local/lib/python3.12/site-packages/ydb/_session_impl.py\", line 20, in decorator
    return func(rpc_state, response_pb, session_state, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/local/lib/python3.12/site-packages/ydb/_session_impl.py\", line 237, in wrap_keep_alive_response
    issues._process_response(response_pb.operation)
  File \"/usr/local/lib/python3.12/site-packages/ydb/issues.py\", line 226, in _process_response
    raise exc_obj(_format_response(response_proto), response_proto.issues)
    ydb.issues.BadSession: message: \"Session not found.\" severity: 1 (server_code: 400100)

Expected behavior:

Task exception is retrieved

Steps to reproduce:

This is some floating bug

Activity

  1. vgvoleg commented on Mar 5, 2025

    @vgvoleg
    Member

    Hi! Can you add more details? BasSession is fine to appear time to time, when server reconnect happens. Can you tell about client side behavior and server side behavior during this error?

  2. vladkolotvin commented on Mar 5, 2025

    @vladkolotvin
    Author

    It's not fine, when task result is not retrieved. It follows that the library may not handle this error.

  3. reopened this on Apr 1, 2026
  4. vgvoleg commented on Apr 1, 2026

    @vgvoleg
    Member

    It's not fine, when task result is not retrieved. It follows that the library may not handle this error.

    hi! is problem still actual? can you provide snippet what are you trying to do? From logs I see that it is Table Service (legacy). Please provide more details or close this issue

  5. vgvoleg commented on Apr 24, 2026

    @vgvoleg
    Member

    Please migrate to Query Service (ydb.QuerySessionPool)

  6. a-s-maslov commented on Oct 31, 2026

    @a-s-maslov

    Связанный PR: #934.

    В текущем main ошибка KeepAlive может не только оставить необработанное исключение, но и потерять слот legacy ydb.aio.SessionPool: после повторных ошибок пул перестаёт выдавать сессии даже после восстановления сервера. В PR есть регрессионные тесты освобождения слота.

    Запрошенный приоритет: Low с учётом legacy Table Service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions