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
- Additional fix for #280. — committed to jtv/libpqxx by jtv 4 years ago
- Streamline check for `PGresult` errors. We were having some problems recognising and reporting errors from libpq functions returning `PGresult`. In particular, we'd query the connection's encoding b... — committed to jtv/libpqxx by jtv 4 years ago
- Tweak errors for unknown/missing SQLSTATE. To deal with #280 (which we can't really fix at this level), treat an SQLSTATE that's either missing or empty as a broken connection. It's a bad choice, bu... — committed to jtv/libpqxx by jtv 4 years ago
@jtv It seem your patch is working for me! It fire the
broken_connectionat the right time.