LOG: 08006: could not send data to client: Broken pipe

What is this error ?
Connection between the server and client is lost.
Why this error ?
- Client created a database connection
- Client sent a query to the database server
- Connection between client to server is lost (client connection got killed)
- Process created at server is still processing the query
- After query processing is done and server tried to send result it didn’t find the client so it gave the error.
Resolution:
- Check the network between the client and server.
- Check the availability of the client machine.
Example:
Client Side:
On client side I created a database connection and executed a long running query and killed it after some time.
-bash-4.2$ /usr/pgsql-9.6/bin/psql -h 192.168.159.135 -p 5433 -d compliance -U postgres
Password for user postgres:
psql (9.6.17)
Type "help" for help.
compliance=# select * from test_acc order by aid ;
Killed
-bash-4.2$
[root@localhost ~]# kill -9 4013 -- Killed the client process explicitly
Server Side:
On server side I monitored and found the connection is not closed and query is still running. Once the query execution is done, server tried to send data back to client and failed.
--- Still connection exists
postgres=# select * from pg_stat_activity ;
-[ RECORD 1 ]----+--------------------------------------
datid | 73767
datname | compliance
pid | 14263
usesysid | 10
usename | postgres
application_name | psql
client_addr | 192.168.159.130
client_hostname |
client_port | 52286
backend_start | 2020-05-06 08:12:59.559797-07
xact_start | 2020-05-06 08:13:52.54512-07
query_start | 2020-05-06 08:13:52.54512-07
state_change | 2020-05-06 08:13:52.545123-07
wait_event_type |
wait_event |
state | active
backend_xid |
backend_xmin | 924769
query | select * from test_acc order by aid ;
--- After some time the error log of the server gave this message.
2020-05-06 08:14:44 PDT:192.168.159.130(52286):postgres@compliance:[14263]:LOG: 08006: could not send data to client: Broken pipe
2020-05-06 08:14:44 PDT:192.168.159.130(52286):postgres@compliance:[14263]:LOCATION: internal_flush, pqcomm.c:1441
2020-05-06 08:14:44 PDT:192.168.159.130(52286):postgres@compliance:[14263]:STATEMENT: select * from test_acc order by aid ;
2020-05-06 08:14:44 PDT:192.168.159.130(52286):postgres@compliance:[14263]:FATAL: 08006: connection to client lost
2020-05-06 08:14:44 PDT:192.168.159.130(52286):postgres@compliance:[14263]:LOCATION: ProcessInterrupts, postgres.c:2912
2020-05-06 08:14:44 PDT:192.168.159.130(52286):postgres@compliance:[14263]:STATEMENT: select * from test_acc order by aid ;
An interesting discussion is definitely worth comment. I do believe that you should publish more on this issue, it might not be a taboo matter but usually people do not speak about such topics. To the next! Many thanks!!
LikeLike