Re: psycopg2 conn.poll() hangs when used with sshtunnel

From: Akshay Joshi <akshay(dot)joshi(at)enterprisedb(dot)com>
To: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: psycopg2 conn.poll() hangs when used with sshtunnel
Date: 2018-10-30 14:50:14
Message-ID: CANxoLDehW575yUmu649dLA3gJ7Q+1SnkL80ohEqE56tQ-GDVdg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

Thanks Daniele

On Tue, 30 Oct 2018, 19:56 Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com
wrote:

> On Tue, Oct 30, 2018 at 1:55 PM Akshay Joshi <
> akshay(dot)joshi(at)enterprisedb(dot)com> wrote:
>
>> Hi
>>
>> On Tue, 30 Oct 2018, 19:17 Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com
>> wrote:
>>
>>> It seems to me that the problem is in pqpath.c pq_get_last_result()
>>> function. The loop assumes PQgetResult won't block, which seems always the
>>> case with the direct connection, but PQisBusy() actually returns 1
>>> connecting through the tunnel.
>>>
>>> So at a first read, the simplification given by pq_get_last_result() is
>>> broken: the results should be returned one by one in the normal loop going
>>> through PQisBusy(), PQconsumeInput(), and the polling machinery. It seems a
>>> chunky refactoring but as it is now I don't like pq_get_last_result()
>>> anymore :(
>>>
>>
>> What changes should I made to fix this? Or it should be fixed in
>> psycopg2 itself.
>>
>
> It is a problem in psycopg. I have a quick fix I can release with the next
> bugfix if it shows no regression (
> https://github.com/psycopg/psycopg2/issues/801) A better fix requires a
> non trivial rewrite of the async and green paths (
> https://github.com/psycopg/psycopg2/issues/802) I'd like to do it but it
> may happen later if the band aid holds.
>
> I was just about to prepare the 2.7.6 release, so if the quick fix is easy
> and doesn't cause regressions it will be released soon.
>
> -- Daniele
>
>

In response to

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2018-10-30 15:36:01 Re: psycopg2 conn.poll() hangs when used with sshtunnel
Previous Message Daniele Varrazzo 2018-10-30 14:26:38 Re: psycopg2 conn.poll() hangs when used with sshtunnel