Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

bug: `ydb.aio.retry_operation` retains memory on exceptions chained from Pydantic validation errors

已关闭
#905 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
50/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

Start at the ydb.aio.retry_operation entry point and build the reported Python 3.12/Pydantic 2.13.4 reproduction, comparing it with directly awaiting the coroutine. Trace the retry result, application exception, ValidationError, traceback, and coroutine references; done means otherwise-unreferenced locals are collectible after handling the exception and running gc.collect().

由索引模型根据 Issue 内容生成。

描述

bug

Bug Report

Coroutine-local objects remain alive after ydb.aio.retry_operation propagates an application exception chained from a Pydantic ValidationError, even after the caller handles the exception and explicitly runs gc.collect(). No database connection is required to reproduce this.

YDB Python SDK version:

version 3.31.4

Environment

Environment: Python 3.12, Pydantic 2.13.4, pydantic-core 2.46.4.

Current behavior:

  • Directly awaiting the same coroutine releases its local objects.
  • Calling it through ydb.aio.retry_operation retains them.
  • A simple application exception without the validation-error cause did not reproduce the retention.

The observed reference chain is:

YdbRetryOperationFinalResult
  → application exception
  → Pydantic ValidationError
  → traceback
  → coroutine frame and local objects

Possible Pydantic-specific interaction: the reproduction uses a union of custom validators that raise ValueError. Pydantic can retain these underlying exceptions as validation-error context, potentially adding traceback references to the retry-state cycle. Its native implementation may be relevant to why the objects survive garbage collection, but this mechanism has not been established.

Expected behavior:

Once the operation has failed and the caller has handled the exception, otherwise-unreferenced coroutine locals should be collectible.

Steps to reproduce:

  • Create a coroutine that allocates a local object and triggers a Pydantic validation error using a union of failing custom validators.
  • Raise an application exception chained from that ValidationError.
  • Compare directly awaiting the coroutine with calling it through ydb.aio.retry_operation.
  • Handle the exception, run garbage collection, and check the local object through a weak reference.
  • In the tested reproduction, the direct call released the object, while the SDK retry call retained it.
主要语言
Python
星标
102
派生
77
平均合并
2 天 17 小时
30 天内合并 PR
11

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ydb-platform/ydb-python-sdk 的其他 Issue

查看 ydb-platform/ydb-python-sdk 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。