第 12 篇 Dify 入坑记录:database插件连接未关闭

文章目录

背景

Dify 1.7.1 社区版中需要使用数据库插件,执行相关的数据库查询操作。使用的插件如下:database 0.0.6

😱 存在的问题 :执行 SQL 后,数据库连接没有关闭,在生产上甚至提示连接处于 in transaction 状态中,导致其它事务卡住。

排查

database 中找到插件的 GitHub 地址:https://github.com/hjlarry/dify-plugin-database

有几个类似的 GitHub issue:

1、https://github.com/hjlarry/dify-plugin-database/issues/44

提到添加 {"pool_recycle":60} 可以缓解问题。查了下 pool_recycle 的参数定义:Engine Configuration --- SQLAlchemy 2.0 Documentation

可以理解为,**这个设置在指定秒数后会回收掉连接。**默认值为-1,表示永远不会回收。例如,设置为 3600,则表示连接将在一小时后回收。如果设置为 60,则表示 60 秒后会回收掉这个连接。


2、https://github.com/hjlarry/dify-plugin-database/issues/107

从代码上看,有点 bug,所以还没有啥解决办法。有的人甚至已经自己弄了 http 请求来执行 SQL。

解决

由于加上 {"pool_recycle":60} 配置只能缓解,不能根治。故考虑更换数据库插件,改为 Database Query

更换后, 不存在数据库连接未关闭的问题了。😁

参考

1.database

2.Database Query

3.https://github.com/hjlarry/dify-plugin-database/issues/44

4.https://github.com/hjlarry/dify-plugin-database/issues/107

相关博文

1.第 1 篇 Linux 下部署 Dify 1.7.1

2.第 2 篇 Dify 插件离线安装

3.第 3 篇 Dify 入门示例 - 聊天助手

4.第 4 篇 Dify 示例:数据库执行Agent

5.第 5 篇 Dify 报错解决:The length of output variable xxx must be less than 30 elements

6.第 6 篇 Dify 接入大模型并使用

7.第 7 篇 Dify 应用介绍 + 聊天助手&Agent 应用关键点说明

8.第 8 篇 RAG 必知概念及原理详解

9.第 9 篇 Dify 知识库原理详解

10.第 10 篇 Dify 知识库手把手案例

11.第 11 篇 Dify 入坑记录:插件安装报错,[ERROR]init environment failed_ failed to install dependencies

12.第 12 篇 Dify 入坑记录:database插件连接未关闭

相关推荐
LgZhu(Yanker)6 小时前
R/3 销售与分销
大数据·网络·数据库·sap·erp·销售
mit6.8246 小时前
[nanoGPT] configurator.py | exec() & globals()
人工智能
rengang667 小时前
132-Spring AI Alibaba Vector Neo4j 示例
人工智能·spring·neo4j·rag·spring ai·ai应用编程
mit6.8247 小时前
[nanoGPT] 性能与效率 | `torch.compile()` |`Flash Attention`|`混合精度训练`|`estimate_mfu`
人工智能
豆芽脚脚7 小时前
机器学习之数字识别
人工智能·机器学习
智海观潮8 小时前
Flink在与AI集成的路上再次“遥遥领先” - Flink Agents
大数据·人工智能·flink
tebukaopu1489 小时前
mysql如何强制区分大小写
数据库·mysql
honeysuckle_luo9 小时前
RandLA-net-pytorch 复现
人工智能·pytorch·python
_BugMan10 小时前
【大模型】理论基础(1):函数与神经网络
人工智能·深度学习·神经网络