Why are we using blocking libpq in the backend?

Started by Andres Freundover 3 years ago1 messageshackers
Jump to latest
#1Andres Freund
andres@anarazel.de

Hi,

As noted in [1]/messages/by-id/20230103200520.di5hjebqvi72coql@awork3.anarazel.de, and also commented on by other previously, we use libpq in
blocking mode in libpqwalreceiver, postgres_fdw, etc. This is done knowingly,
see e.g. comments like:
/*
* Submit the query. Since we don't use non-blocking mode, this could
* theoretically block. In practice, since we don't send very long query
* strings, the risk seems negligible.
*/

but I don't understand why we do it. It seems like it'd be a fairly small
amount of additional code to just do it right, given that we do so for calls
to PQgetResult() etc?

Greetings,

Andres Freund

[1]: /messages/by-id/20230103200520.di5hjebqvi72coql@awork3.anarazel.de