On 20 December 2013 19:43, MauMau Wrote
> [Problem]
> If the backend is terminated with SIGKILL while psql is running "\copy
> table_name from file_name", the \copy didn't end forever.  I expected
> \copy
> to be cancelled because the corresponding server process vanished.
> [Cause]
> psql could not get out of the loop below in handleCopyIn():
> while (res = PQgetResult(conn), PQresultStatus(res) == PGRES_COPY_IN)
> {
>     OK = false;
>     PQclear(res);
>     PQputCopyEnd(pset.db, _("trying to exit copy mode"));
> }

1. Patch applied to git head successfully
2. Problem can occur in some scenario and fix looks fine to me.
3. For testing, I think it's not possible to directly generate such scenario, 
so I have verified by debugging as the steps explained.

        1. Make pqsecure_write to return less byte(by updating the result while 
debugging in gdb  in pqSendSome.
        (also make sure that remaining byte is >= 8192 i.e conn->outCount-sent 
> 8192 , so that in next step pqPutMsgEnd called from PQputCopyEnd go for 
flushing the data)

        2. Then Kill the backend process before it calls pqReadData.

        Scenario reproduced without patch and after applying the patch issue 

Is there any direct scenario by which it can be reproduce ?



Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to