You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SSIS执行PostgreSQL长时ODBC查询超时并抛出“连接已禁用”错误求助

SSIS执行PostgreSQL长时ODBC查询超时并抛出“连接已禁用”错误求助

各位好,我最近在VS Community里开发SSIS包时碰到了一个棘手的问题,折腾了好几天没找到原因,想请大家帮忙分析下:

我在包里面用了Execute SQL Task组件来执行PostgreSQL的查询,组件的各项配置如下:

  • 常规设置:
    General设置
  • 参数映射:
    Mapping设置
  • 结果集设置:
    ResultSet设置
  • 表达式设置:
    Expressions设置

连接方面,我用的是ADO.NET的Odbc Data Provider连接PostgreSQL(SSIS跑在Windows上,PostgreSQL部署在Ubuntu服务器,用的是官方ODBC驱动),连接配置和连接字符串如下:
Connection设置

Driver={PostgreSQL Unicode(x64)};server=<ip>;uid=<username>;database=<dbname>;port=<portnum>;sslmode=disable;readonly=0;protocol=7.4;fakeoidindex=0;showoidcolumn=0;rowversioning=0;showsystemtables=0;fetch=100;unknownsizes=0;maxvarcharsize=255;maxlongvarcharsize=8190;debug=0;commlog=0;usedeclarefetch=0;textaslongvarchar=1;unknownsaslongvarchar=0;boolsaschar=1;parse=0;lfconversion=1;updatablecursors=1;trueisminus1=0;bi=0;byteaaslongvarbinary=1;useserversideprepare=1;lowercaseidentifier=0;d6=-101;optionalerrors=0;fetchrefcursors=0;xaopt=1;ab=40

还有连接的详细配置页面:
Connection设置-页面1
Connection设置-页面2
Connection设置-页面3

问题现象

包启动时一切正常,我用PostgreSQL的select * from pg_stat_activity监控查询执行,发现查询在服务器上已经执行完成后,SSIS包却一直停留在运行状态,直到超时时间到了之后抛出错误:
[Execute SQL Task] Error: Executing the query failed with the following error: "The connection has been disabled.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
错误截图

执行的SQL脚本示例

我运行的SQL脚本结构大概是这样的:

begin;
update table1 where <condition1>
commit;
begin;
update table1 where <condition2>
commit;

排查到的规律

我反复测试后发现,问题的核心触发因素是查询执行时间:

  • 如果查询实际执行时间在3分钟左右,完全没问题;
  • 一旦执行时间超过20分钟,就一定会触发这个问题;
  • 哪怕只有一个长时查询也会中招,而且PostgreSQL上的查询还在正常运行(没有被终止),SSIS这边却会在1小时后准时抛出超时错误;
  • 另外测试了一个执行时间6分50秒的查询,完全正常:
    6分50秒查询正常截图

现在实在找不到问题出在哪了,有没有碰到过类似情况的朋友,或者有排查思路的大佬,麻烦给点建议,谢谢大家了!


备注:内容来源于stack exchange,提问作者Алексей Корсак

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.13 18:25:30