libpqxx: Bad exception sql_error in place of broken_connection?

Hello,

I’m using Ubuntu x64 in 18.04 Libpqxx 7.0.1 Libpq version 12.0.1

Here is my test case: I’m opening a connection to my PG server with the field tcp_user_timeout at 10000 (10 seconds). Everything is good here. Then I unplug my Ethernet cable and do an insert in database (with a work object on my connection) It stall for about 10 seconds (the amount of the value of tcp_user_timeout) and then an pqxx::sql_error exception is throwed with the message equal to Connection timed out.

In the libpq documentation it is noted that the connection is forcibly closed when this arrive:

tcp_user_timeout Controls the number of milliseconds that transmitted data may remain unacknowledged before a connection is forcibly closed. A value of zero uses the system default. This parameter is ignored for connections made via a Unix-domain socket. It is only supported on systems where TCP_USER_TIMEOUT is available; on other systems, it has no effect.

So I was expecting to get a pqxx::broken_connection but it is not the case. I only get pqxx::broken_connection when I connect to database but not after.

Also I checked the connection function is_open() when this arrive, and it return true when Timeout occur. Is there a solution to get a pqxx::broken_connection when server is not reachable for my example in 10s when doing a request?

Regards

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 35 (20 by maintainers)

Commits related to this issue

Most upvoted comments

@jtv It seem your patch is working for me! It fire the broken_connection at the right time.