dbdpg icon indicating copy to clipboard operation
dbdpg copied to clipboard

Fixed hangup of execution of queries like "COPY TO STDIN" in asynchronous mode.

Open true-alex opened this issue 2 years ago • 4 comments

The problem is in the wrong sequence of calls when processing the result of calling the COPY command in asynchronous mode. https://github.com/bucardo/dbdpg/issues/98

The problem is that the pg_db_result method tries to get the result of the query before it completes. The result of the COPY command will be only after the end of reading / writing the data stream.

Perhaps the problem can be solved differently, I did not want to change the source code much.

true-alex avatar Sep 29 '22 12:09 true-alex

Do you have a working test script that demonstrates this? While digging in, I found some other issues with regards to async COPY so I want to make sure I fix it all at once.

turnstep avatar Aug 23 '23 14:08 turnstep

A lot of time has passed, the server is already down. According to the results of experiments, I refused to use asynchronous COPY due to the fact that it did not speed up, but only saved memory (I had enough memory). Only test cases remained, which are also tied to task #98. https://github.com/bucardo/dbdpg/files/9491191/test.tgz

true-alex avatar Aug 23 '23 16:08 true-alex

Thank you. I think we are simply going to disallow calling pg_result after an asynchronous COPY, as it's not the same as the non-COPY cases where we can simply wait for the server to finish.

turnstep avatar Aug 23 '23 20:08 turnstep

In the current version of the module, if pg_result is not called after a successful pg_ready, an error will occur, since pg_result sets the status of waiting for data from COPY.

true-alex avatar Aug 28 '23 10:08 true-alex