unable to read data from frontend
prognik opened this issue · 4 comments
Hello,
We have microservices app in k8s. The Kong API Gateway is one of the services. Kong uses pgmoon library for connect to PostgreSQL. All services connect to there own databases through pgpool load balancer.
In pgpool log the follows error is often appeared:
pgmoon [10170] kong@kongdb ERROR: unable to read data from frontend
pgmoon [10170] kong@kongdb DETAIL: EOF encountered with frontend
We asked pgpool developer about this error. They replied that perhaps pgmoon does not follow the procedure of the PostgreSQL protocol
https://www.postgresql.org/docs/13/protocol-flow.html#id-1.10.5.7.10
And they advised us contact pgmoon developers.
Could you help us in this?
Thanks in advance.
Regards,
Nikola
If you're using pgmoon through openresty then the connection pool is managed by the openresty coscoket pool. There's no way, as far as I know, to control how those sockets are closed. When the socket is relinquished, the connection is closed with no opportunity to send a terminate message.
Additionally, when a pgmoon connection instance is garbage collected, it will also just close the socket without executing any additional code.
Although, I do see that the manual disconnect method in pgmoon does not issue the terminate message, it just closes the socket. I've updated it to send the terminate message.
@leafo thank you for your reply. You said that you updated pgmoon and pgmoon now will send a terminate message after closing the connection. Did I understand you correctly? If so, could you tell me how I can apply updated pgmoon on applications that use pgmoon, for example, kong API gateway?
Given the kong is running on openresty it's unlikely that my change will have any effect on those log messages, since I'm assuming they are by default using the openresty connection pool which automatically manages the sockets. If there's an option for you to turn off connection pooling within kong then perhaps it might be able to use an explicit disconnect call that would send the terminate message. Additionally, I believe that kong is using a fork of the pgmoon library vendored into their project, so you may have to take that into account.
I would say that this error message, for this particular case, is safe to ignore. The postgres server itself does not show any errors or warnings when a frontend disconnects by closing the connection as far as I know.