Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fc70M-0001Q4-2t for pgsql-odbc@arkaria.postgresql.org; Sun, 08 Jul 2018 10:33:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fc70J-0000ZW-Jo for pgsql-odbc@arkaria.postgresql.org; Sun, 08 Jul 2018 10:33:19 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fc70J-0000ZP-9S for pgsql-odbc@lists.postgresql.org; Sun, 08 Jul 2018 10:33:19 +0000 Received: from mail03.asahi-net.or.jp ([202.224.55.15]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fc70A-0004XA-2b for pgsql-odbc@postgresql.org; Sun, 08 Jul 2018 10:33:16 +0000 Received: from [192.168.1.5] (p171004-ipngn200303fukui.fukui.ocn.ne.jp [180.5.50.4]) (Authenticated sender: GQ9H-INUE) by mail03.asahi-net.or.jp (Postfix) with ESMTPA id 07CC9E8212; Sun, 8 Jul 2018 19:33:03 +0900 (JST) Subject: Re: ODBC cliens is hanging if network connection is broken To: AYahorau@ibagroup.eu Cc: pgsql-odbc@postgresql.org, MikalaiKeida@ibagroup.eu References: From: "Inoue, Hiroshi" Message-ID: Date: Sun, 8 Jul 2018 19:33:11 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------4C8EBEDFC46338DAD908A470" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------4C8EBEDFC46338DAD908A470 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi, On 2018/07/07 21:37, AYahorau@ibagroup.eu wrote: > Hello PostgreSQL Community! > > I downloaded and installed the latest version of PostgreSQL from > https://www.postgresql.org/ftp/source/v10.4/on my SLES 12 system. > Here is my configuration of unixODBC: > > odbcinst,ini > [PostgreSQL] > Description=PostgreSQL ODBC driver > Driver=/usr/local/lib/psqlodbcw.so > FileUsage=1 > > odbc.ini > [sles12-1] > Description = PostgreSQL connection to rtpdb > Driver = PostgreSQL > Database = rtpdb > Servername = sles12-1 > Username = > Password = > Port = 5432 > Protocol = 7.4+ > ReadOnly = No > RowVersioning = No > ShowSystemTables = No > ConnSettings = > > As a Driver in odbcinst.ini I specified the path to *psqlodbcw.so > *which was downloaded from > https://git.postgresql.org/gitweb/?p=psqlodbc.gitand built as follows: > ./configure > make > make install > > Could you please provide a comment concerning the following situation? > > I  created a simple ODBC program which calls "*SELECT > pg_is_in_recovery()*" on the remote PostgreSQL server using ODBC API. > It works good with this ODBC configuration. But as soon as I turn off > network interface after *SQLConnect *call and before *SQLExecDirect*, > it leads to *SQLExecDirect *hanging. > > I tried to use *statement_timeout* and > *idle_in_transaction_session_timeout* postgresql configuration > parameters but they were not suitable for network issue case. These > parameters define server-side behaviour but a client considers that > the connection is ok and it is hanging. > > > As far as I know *SQL_ATTR_CONNECTION_TIMEOUT *ODBC attribute could > handle this situation. Another ODBC driver for another database in > case of similar situation returns *HYT01 *ODBC error (Connection > timeout expired) . But I guess *SQL_ATTR_CONNECTION_TIMEOUT * is not > supported by psqlodbc.  Am I right? How about calling SQLSetStmtAttr() with the attribute parameter SQL_ATTR_QUERY_TIMEOUT? > > > PostgreSQL JDBC driver provides *socketTimeout*property which helps a > client to be informed about network problems and to avoid an infinite > hanging. > In my tests it returned *08006 *sqlstate (*connection_failure*). > > So I have a question. Is there any psqlodbc or native PostgreSQL > mechanism or configuration parameter which helps a client to be > informed about network problem? > Is there any mechanism which helps to avoid this infinite hanging for > SQL query in this case? > > Thank You in advance, > Andrei Yahorau --------------4C8EBEDFC46338DAD908A470 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Hi,

On 2018/07/07 21:37, AYahorau@ibagroup.eu wrote:
Hello PostgreSQL Community!

I downloaded and installed the latest version of PostgreSQL from
https://www.postgresql.org/ftp/source/v10.4/ on my SLES 12 system.
Here is my configuration of unixODBC:


odbcinst,ini
[PostgreSQL]
Description=PostgreSQL ODBC driver
Driver=/usr/local/lib/psqlodbcw.so
FileUsage=1

odbc.ini
[sles12-1]
Description = PostgreSQL connection to rtpdb
Driver = PostgreSQL
Database = rtpdb
Servername = sles12-1
Username =
Password =
Port = 5432
Protocol = 7.4+
ReadOnly = No
RowVersioning = No
ShowSystemTables = No
ConnSettings =

As a Driver in odbcinst.ini I specified the path to psqlodbcw.so which was downloaded from https://git.postgresql.org/gitweb/?p=psqlodbc.git and built as follows:
./configure
make
make install


Could you please provide a comment concerning the following situation?

I  created a simple ODBC program which calls "SELECT pg_is_in_recovery()" on the remote PostgreSQL server using ODBC API. It works good with this ODBC configuration. But as soon as I turn off network interface after SQLConnect  call and before SQLExecDirect, it leads to SQLExecDirect hanging.

I tried to use statement_timeout
 and idle_in_transaction_session_timeout  postgresql configuration parameters but they were not suitable for network issue case. These parameters define server-side behaviour but a client considers that the connection is ok and it is hanging.



As far as I know SQL_ATTR_CONNECTION_TIMEOUT ODBC attribute could handle this situation. Another ODBC driver for another database in case of similar situation returns HYT01  ODBC error (Connection timeout expired) . But I guess  SQL_ATTR_CONNECTION_TIMEOUT  is not supported by psqlodbc.  Am I right?

How about calling SQLSetStmtAttr() with the attribute parameter SQL_ATTR_QUERY_TIMEOUT?



PostgreSQL JDBC driver provides
socketTimeout property which helps a client to be informed about network problems and to avoid an infinite hanging.
In my tests it returned 08006 sqlstate (connection_failure ).

So I have a question. Is there any psqlodbc or native PostgreSQL mechanism or configuration parameter which helps a client to be informed about network problem?
Is there any mechanism which helps to avoid this infinite hanging for SQL query in this case?


Thank You in advance,
Andrei Yahorau
--------------4C8EBEDFC46338DAD908A470--