public inbox for [email protected]  
help / color / mirror / Atom feed
From: Akshay Joshi <[email protected]>
To: Daniele Varrazzo <[email protected]>
Cc: [email protected]
Subject: Re: psycopg2 conn.poll() hangs when used with sshtunnel
Date: Tue, 30 Oct 2018 19:24:51 +0530
Message-ID: <CANxoLDfDw=9oAePwZk0Su9PLB3ni_NQdJ5Lj1k21GzYe07sY8Q@mail.gmail.com> (raw)
In-Reply-To: <CA+mi_8boc=n4jZnX+20-UYwZYd4wse+wrnZWf6zG-1nMhDLmnA@mail.gmail.com>
References: <CANxoLDc4AosChXUhArLh2ufdon1BRwhCNRgGjyeCsYf9vHTmTw@mail.gmail.com>
	<CANxoLDf3ra5UaqFw_6A824_hAi5XPykySr+DJre2ZbprbxTCVA@mail.gmail.com>
	<CANxoLDesBkV9=qpg22-9nG=JYgvUuo3Xm+iDxSWwLVReTiEC7g@mail.gmail.com>
	<CA+mi_8ZBYkPm7Kou8smEnDfXPPjVByw7o3M-nY3PvVEK_TN9nA@mail.gmail.com>
	<CA+mi_8boc=n4jZnX+20-UYwZYd4wse+wrnZWf6zG-1nMhDLmnA@mail.gmail.com>

Hi

On Tue, 30 Oct 2018, 19:17 Daniele Varrazzo <[email protected]
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.

>
> -- Daniele
>
>
> On Tue, Oct 30, 2018 at 12:52 PM Daniele Varrazzo <
> [email protected]> wrote:
>
>> Taking a look. Thank you for the test.
>>
>> On Tue, Oct 30, 2018 at 12:36 PM Akshay Joshi <
>> [email protected]> wrote:
>>
>>> Hi Team
>>>
>>> I have created one sample application to replicate the issue. Attached
>>> is the sample application, please read "README.txt" file to proceed further.
>>> Can someone please suggest why poll() function hangs when run wrong
>>> query with sshtunnel v0.1.4.
>>>
>>> On Mon, Oct 8, 2018 at 12:19 PM Akshay Joshi <
>>> [email protected]> wrote:
>>>
>>>> Hi Team
>>>>
>>>> As one issue(*https://github.com/psycopg/psycopg2/issues/781
>>>> <https://github.com/psycopg/psycopg2/issues/781>*) has already been
>>>> created for conn.poll() function hangs when executes COPY command in async
>>>> mode. Similarly conn.poll() functions hangs when we run wrong query in
>>>> async mode using sshtunnel <https://pypi.org/project/sshtunnel/;
>>>>  v0.1.3.
>>>>
>>>> Can someone please suggest what went wrong when used sshtunnel, or the
>>>> pointers/reason where poll() method hangs.
>>>>
>>>> On Fri, Sep 28, 2018 at 5:43 PM Akshay Joshi <
>>>> [email protected]> wrote:
>>>>
>>>>> Hello
>>>>>
>>>>> I am using psycopg2 2.7.4 to connect to the PostgreSQL database
>>>>> server using asynchronoussupport. It is working absolutely fine. I
>>>>> have used sshtunnel <https://pypi.org/project/sshtunnel/; v0.1.3 in
>>>>> pgAdmin4. When I connect the PostgreSQL database server using ssh
>>>>> tunnel and run the valid/correct query it works fine, but when I run any
>>>>> wrong query(invalid column of table) my application gets hang on
>>>>> conn.poll() function.
>>>>>
>>>>> Please refer the code how we use conn.poll() with timeouts
>>>>> https://git.postgresql.org/gitweb/?p=pgadmin4.git;a=blob;f=web/pgadmin/utils/driver/psycopg2/connect...
>>>>>
>>>>> Can anyone please provide some pointers, suggestions?
>>>>>
>>>>> --
>>>>> *Akshay Joshi*
>>>>>
>>>>> *Sr. Software Architect *
>>>>>
>>>>>
>>>>>
>>>>> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>>>>>
>>>>
>>>>
>>>> --
>>>> *Akshay Joshi*
>>>>
>>>> *Sr. Software Architect *
>>>>
>>>>
>>>>
>>>> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>>>>
>>>
>>>
>>> --
>>> *Akshay Joshi*
>>>
>>> *Sr. Software Architect *
>>>
>>>
>>>
>>> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>>>
>>


view thread (11+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: psycopg2 conn.poll() hangs when used with sshtunnel
  In-Reply-To: <CANxoLDfDw=9oAePwZk0Su9PLB3ni_NQdJ5Lj1k21GzYe07sY8Q@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox