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 ?

  1. Client created a database connection
  2. Client sent a query to the database server
  3. Connection between client to server is lost (client connection got killed)
  4. Process created at server is still processing the query
  5. After query processing is done and server tried to send result it didn’t find the client so it gave the error.

Resolution:

  1. Check the network between the client and server.
  2. 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 ;

One comment

  • 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!!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s