Disable nonblocking mode while large object calls #498
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This came up here: lsylvester/active_storage-postgresql#16 It fails for me with the
unexpected response from server; first received character was "V"
in their test suite.libpq's "lo_*" calls fail when a bigger amount of data is transferred and the connection is set to nonblocking mode. According to some discussion here
https://www.postgresql.org/message-id/20130606.082048.998330612674120762.t-ishii%40sraoss.co.jp
the large object interface isn't intended to be used with nonblocking mode.
It works to some extend with small data (< 8000 Bytes), but fails after lo_write of bigger data at the next exec call on the same connection like so:
I think the best solution is to disable nonblocking mode for the time of the lo_* call. Calling PQisnonblocking and PQsetnonblocking is very low overhead, since these functions do a few memory operations only.
Fixes #460
/CC @Nerian