Bootstrap

ODBC连接PostgreSQL数据库后,网卡DOWN后,客户端进程阻塞问题解决方法

问题现象:数据库客户端进程数据库连接成功后,再把跟数据库交互的网卡down掉,客户端进程就会阻塞,无法进行其他处理。该问题跟TCP keepalive机制有关。

可以在odbc.ini文件中增加相应的属性来解决,在odbc.ini 增加如下内容:

pqopt = keepalives=1 keepalives_idle=5 keepalives_count=1 keepalives_interval=1

 odbc.ini:

[sles12-1]
Description = PostgreSQL connection to rtpdb
Driver = PostgreSQL
Database = rtpdb
pqopt = keepalives=1 keepalives_idle=5 keepalives_count=1 keepalives_interval=1
Servername = sles12-1
Username =
Password =
Port = 5432
Protocol = 7.4+
ReadOnly = No
RowVersioning = No
ShowSystemTables = No

参考链接:Thread: ODBC cliens is hanging if network connection is broken : Postgres Professional

;