Handling error during async query - Mailing list pgsql-general

From Daniele Varrazzo
Subject Handling error during async query
Date
Msg-id CA+mi_8Y-a_H+w28T+y0Z1BEopVCgxc4x1xSugps6znAMBGgnwg@mail.gmail.com
Whole thread Raw
List pgsql-general
Hello,

I'm trying to fix psycopg2 issue #113: network disconnection not
handled correctly in async mode.

If I'm in the middle between the PQsendQuery and the PQgetResult and
an error is detected (let's say we don't know yet if
application-related or connection-related), is there a way to abort
the query and put it back in a status where PQsendQuery can be
executed again (I believe transaction status from ACTIVE to IDLE)
without fetching the result?

Psycopg currently tries to fetch (blocking) and discard the result
after an error:

    while (NULL != (res = PQgetResult(conn->pgconn))) {
        PQclear(res);
    }

but if the network connection has gone down it will result in waiting
forever. Not to mention the fact the operation is blocking when the
user wanted nonblocking operations.


-- Daniele

pgsql-general by date:

Previous
From: "James W. Wilson"
Date:
Subject: Re: problem with dblink and "drop owned by"
Next
From: "Bob Pawley"
Date:
Subject: Re: Trouble with NEW