Skip to content

[Feature] Auto disconnect after idle timeout #10336

Closed

Description

@gogoout

数据库类型和版本 / Database type and version

General

支持信息 / Support information

DBX Version: v0.6.23
Runtime: Desktop
Operating System: macOS 27.0
Architecture: aarch64

当前痛点 / Current pain point

Long running session sometime would saturate db pool connection. It would be good if it could auto disconnect after sometime.

期望方案 / Proposed solution

Adding auto disconnect option in the connection settings.

优先级(是否紧急) / Priority (urgency)

🟡 P2 普通 · 按排期处理 / Normal · Schedule as appropriate

补充信息 / Additional information

No response

Activity

  1. added
    ai-priority/P2AI: normal repair/implementation priority; schedule as appropriate
    on Sep 26, 2026
  2. zipg commented on Sep 26, 2026

    @zipg
    Collaborator

    先把本地排查到的现状留在这里,方便后续决定怎么落地(这是个需求类 issue,涉及会话生命周期的取舍,我没有直接改)。

    现状(最新 main)

    1. 连接配置里已经存在 idle_timeout_secs 字段(crates/dbx-types/src/models/connection.rs,默认 60),并且不是空挂:
      • MySQL 系(Mysql,以及走 connect_mysql_metadata_pool / connect_bare_mysql_pool_with_setup 的兼容类型)会把它传给 create_pool() 的 with_inactive_connection_ttl(注意 <30 会被回落到 300 秒);
      • MongoDB native driver 也会用它(connect_with_oidc(..., idle_timeout, ...))。
    2. 但它只影响连接池里空闲连接的回收,语义是“池内空闲连接可被断开”,不是“空闲会话自动断开”。
    3. 真正和 issue 里“长会话打满连接池”相关的是会话级连接池:crates/dbx-core/src/connection/mod.rs 里会话级池被有意豁免空闲超时(session_scoped_pool_is_not_closed_by_idle_timeout),只有在关闭标签/会话(close_client_session_pool)时才释放。
    4. UI 上这个字段目前只在 form.db_type === 'mongodb' 时显示(ConnectionDialog.vue 的 v-show),所以 MySQL 用户既看不到、也改不了这个实际上生效的超时。

    可能的两种落地方向

    • A(小):只做配置暴露 —— 把已有的「空闲超时(秒)」在 MySQL 系连接上也显示出来,并在文案里说明它作用于“池内空闲连接回收”。改动小、不改语义。
    • B(大):真的实现“空闲 N 分钟自动断开会话/关闭空闲标签”,需要定义“空闲”的口径(无查询?无标签页焦点?)、是否可取消、以及与会话内临时表/事务的交互——这属于产品决策,建议先确认要做哪一种再动手。

    如果倾向 B,我可以按 A 先补一个配置暴露的小改动;如果只想要 A 的语义,直接提 PR 也行。

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

    ai-priority/P2AI: normal repair/implementation priority; schedule as appropriateenhancementNew feature or requestuser-priority/P2User-reported priority: normal

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions