eosphoros-ai / DB-GPT

AI Native Data App Development framework with AWEL(Agentic Workflow Expression Language) and Agents
http://docs.dbgpt.cn
MIT License
13.75k stars 1.86k forks source link

[Bug] [connection] If it runs for a long time, there is a problem that the connection pool leaks and causes inaccessibility. #2043

Open Andy1i opened 1 month ago

Andy1i commented 1 month ago

Search before asking

Operating system information

Linux

Python version information

=3.11

DB-GPT version

main

Related scenes

Installation Information

Device information

cpu: 16c 32g

Models information

default

What happened

  1. 使用 get_raw_session 时, 大部分使用没有主动释放session, 导致连接池长时间占用
  2. RDBMSConnector 类使用 self.session 或者 self._db_sessions 时,未进行主动释放, 导致连接被长时间占用

What you expected to happen

使用上述两个方法时, 是否需要主动释放session, 或者使用上下文 with来关联session, 避免造成session资源的浪费或泄露

How to reproduce

  1. 将系统连接池变小
    • LOCAL_DB_POOL_SIZE=2
    • LOCAL_DB_POOL_OVERFLOW=0
      1. 将数据库连接时连接池变小进行测试
    • image

Additional context

No response

Are you willing to submit PR?