Hello, Takayuki. > > > For example, OS issues such as abnormally (buggy) slow process scheduling > > or paging/swapping that prevent control from being passed to postgres. Or, > > abnormally long waits on lwlocks in postgres. statement_timeout doesn't > > take effect while waiting on a lwlock. I have experienced both. And, any > > other issues in the server that we haven't experienced and not predictable. > > > > For me all mentioned by Takayuki Tsunakawa problems looks like a lack of > > design of end-user application or configuration of DB server. It is not > > a problem of PostgreSQL.
> Certainly, my cases could be avoided by the OS and database configuration. But we cannot say all such problems can be avoided by configuration in advance. The point is to provide a method to get ready for any situation. Do you mind me asking you whether you have thought that solving your problem can lead to the problem in the other user applications? Let's imagine a possible problem: 1. end-user sets 'socket_timeout' only for current session 2. 'socket_timeout' is much shorter than 'keep_alive', 'tcp_user_timeout' and 'statement_timeout' 3. end-user invokes a 'heavy' query which is not be possible to process by PostgreSQL server within 'socket_timeout' 4. if the query fails due to timeout, terminate the session and repeat it As the query is not cancelled, PostgreSQL server will process it till completion or 'statement_timeout' expiration. In such a case PostgreSQL server can be overloaded by an 'unreliable' user/users and other end-users will not be able to work with PostgreSQL server as they expected. There are a number of timeout parameters which can lead to the terminating a query: 1. keep_alive and tcp_user_timeout terminate a query because of network problems 2. statement_timeout terminates a query because the time for processing this query by PostgreSQL server expired. These timeouts are absolutely different and do not interact with each other. Suggested 'socket_timeout' can replace all mentioned by me timeout parameters because of willing of 'selfish' end-user. 'SocketTimeout' in JDBC was added to cope with network problems when keep_alive and tcp_user_timeout were not implemented. Implementation of the 'socket_timeout' looks like adding a bug into the libpq. I think that the problems you faced, relate to the other issues in PostgreSQL. Best regards, Mikalai Keida