I am experiencing troubles when executing SELECT queries and receiving large (> 550 MB of data) result sets over an ssh tunnel connection. The SELECT query works locally, ie, on the same server where PostgreSQL server lives.
The error messages are, on client side:
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
connection to server was lost
Error message on server side (postgresql.log)
08006: could not receive data from client: Connection reset by peer
When I made the server log more verbose a lot of these appeared but I guess they are unrelated to the problem at hand:
LOG: 08P01: SSL error: unsafe legacy renegotiation disabled
I did not find any postgres option or similar to control “remote result set max size”.
The max memory used before the error happens is around 519 MB (VmData from /proc/PID/status), the query has then run for 1 minutes and 55 seconds. There is no statement_timeout set in postgres conf file.
For the purpose at hand I have to have all the data in the memory at once, so a cursor or something is not an option.
Postgres server version 8.3
Looks like SSL renegotiation is the root of your problem. The default is to renegotiate every 512MB – which is suspiciously close to your description.
In particular, some
olderSSL libraries are incapable of SSL renegotiation – as a safeguard against (old) bugs in the protocol.Try disabling
ssl_renegotiation_limitin yourpostgresql.conf.More about that in the manual (Link to version 8.3).