Postgresql – HAProxy pgsql-check error

haproxyload balancingpostgresql

I use HAProxy 1.5-dev21 to load balance PostgreSQL connections over some read-only Postgresql 9.2 servers.

Version 1.5 of HAProxy implements a pgsql-check option, similar to mysql-check.

Here is my typical HAProxy configuration for such pool:

listen pgsql_pool 0.0.0.0:10001
        mode tcp
        option pgsql-check user postgres
        balance roundrobin
        server slave1 10.0.0.1:5432 check
        server slave2 10.0.0.2:5432 check

That works, I mean HAProxy detects that slave1/slave2 are up and I can connect normally to PG on port 10001, but I see such messages in postgresql logs, every 2 seconds, due to pgsql-check option:

2014-01-29 17:37:33 CET [17170] postgres postgres (10.0.0.10(56706)) LOG:  could not receive data from client: Connection reset by peer
2014-01-29 17:37:35 CET [17173] postgres postgres (10.0.0.10(56707)) LOG:  could not receive data from client: Connection reset by peer

Is there a way to fix this?

Maybe I am missing some configuration option somewhere?

Best Answer

I am not sure if this is really a problem. HAProxy documentation says that

It is a basic but useful test which does not produce error nor aborted connect on the server. This check is identical with the "mysql-check.

Oh the other hand, mysql-check description is little more detailed:

the check consists of sending two MySQL packet, one Client Authentication packet, and one QUIT packet, to correctly close MySQL session

Your log shows exactly this, so I don't think there is anything to worry about, but you might want to wait for pgsql experts or try at dba.stackexchange.com