Repository navigation
Conversation
|
⚪ ⚪
🟢 |
There was a problem hiding this comment.
🟡 Changes recommended
Explicit iterator cancellation can leave calls retained and prevent channel closure, while unjoined daemon cleanup lets driver shutdown return before RPC cancellation and channel closure complete.
2 open issues
What changed in this PR
This PR updates the Python SDK’s connection lifecycle to preserve streaming RPCs during endpoint retirement and force-close current and retired connections at driver shutdown.
Changes:
- Retain connections until streaming RPC completion and move completion-triggered and forced closure to background threads.
- Track retired connections for shutdown and prevent stale removals from deleting replacement connections.
- Add lifecycle regression tests and remove the bridge shutdown workaround.
| File | Description |
|---|---|
ydb/tests/functional/bridge/ya.make |
Registers the streaming cleanup tests. |
ydb/tests/functional/bridge/test_sdk_stream_cleanup.py |
Tests stream retention, cancellation, retirement, and shutdown. |
ydb/tests/functional/bridge/test_sdk_cleanup.py |
Adapts shutdown checks for asynchronous channel closure. |
ydb/tests/functional/bridge/common.py |
Removes the temporary driver cleanup workaround. |
contrib/python/ydb/py3/ydb/pool.py |
Tracks retired connections and makes cache removal identity-safe. |
contrib/python/ydb/py3/ydb/connection.py |
Retains streaming calls and adds asynchronous forced closure. |
contrib/python/ydb/py3/patches/08-retain-streaming-connections.patch |
Records the vendored SDK lifecycle changes. |
Review effort: Balanced
| if isinstance(response, _SafeSyncIterator): | ||
| finish_call = not response.add_callback(lambda: self._finish_call(rpc_state)) |
| if force: | ||
| threading.Thread(target=self.destroy, daemon=True).start() |

Superseded by ydb-platform/ydb-python-sdk#938. The SDK fix and cleanup regression tests are now upstream; YDB will receive the fix through directory sync.
Bridge cleanup-test removal and removal of its SDK workaround are in #58181.