public inbox for [email protected]  
help / color / mirror / Atom feed
Copy command hangs in poll() function
4+ messages / 3 participants
[nested] [flat]

* Copy command hangs in poll() function
@ 2018-10-04 05:35 Akshay Joshi <[email protected]>
  2018-10-04 10:26 ` Re: Copy command hangs in poll() function Daniele Varrazzo <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Akshay Joshi @ 2018-10-04 05:35 UTC (permalink / raw)
  To: psycopg

Hello

As per documentation http://initd.org/psycopg/docs/advanced.html Copy
commands are not supported in asynchronous mode, but this will be probably
implemented in a future release. In pgAdmin4 (open source) we have used
async connection to run the SQL query on PostgreSQL database and uses
poll() function to poll the results. When user runs any *COPY *command
application hangs at poll() function.

If copy command not supported then at least it should not hang the
application. poll() function should return the proper error message.

Can you please provide that fix until support for copy command won't come.


-- 
*Akshay Joshi*

*Sr. Software Architect *



*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Copy command hangs in poll() function
  2018-10-04 05:35 Copy command hangs in poll() function Akshay Joshi <[email protected]>
@ 2018-10-04 10:26 ` Daniele Varrazzo <[email protected]>
  2018-10-04 10:29   ` Re: Copy command hangs in poll() function Daniele Varrazzo <[email protected]>
  2018-10-04 10:33   ` Re: Copy command hangs in poll() function Federico Di Gregorio <[email protected]>
  0 siblings, 2 replies; 4+ messages in thread

From: Daniele Varrazzo @ 2018-10-04 10:26 UTC (permalink / raw)
  To: [email protected]; +Cc: psycopg

On Thu, Oct 4, 2018 at 6:35 AM Akshay Joshi <[email protected]>
wrote:

> Hello
>
> As per documentation http://initd.org/psycopg/docs/advanced.html Copy
> commands are not supported in asynchronous mode, but this will be probably
> implemented in a future release. In pgAdmin4 (open source) we have used
> async connection to run the SQL query on PostgreSQL database and uses
> poll() function to poll the results. When user runs any *COPY *command
> application hangs at poll() function.
>

> If copy command not supported then at least it should not hang the
> application. poll() function should return the proper error message.
>
> Can you please provide that fix until support for copy command won't come.
>

Uhm, I see:

    In [2]: cnn = psycopg2.connect("")
    In [3]: cur = cnn.cursor()
    In [4]: cur.execute("copy (select 1 as x) to stdout")

---------------------------------------------------------------------------
    ProgrammingError                          Traceback (most recent call
last)
    <ipython-input-4-62e3af3d121e> in <module>()
    ----> 1 cur.execute("copy (select 1 as x) to stdout")
    ProgrammingError: can't execute COPY TO: use the copy_to() method
instead

but:

    In [6]: cnn = psycopg2.connect("", async=True)
    In [7]: cnn.poll()
    Out[7]: 2
    In [8]: cnn.poll()
    Out[8]: 1
    In [9]: cnn.poll()
    Out[9]: 0

    In [12]: cur.execute("copy (select 1 as x) to stdout")
    In [14]: cnn.poll()
    ^C -- hung

So yes, I'll take a look if there is a way to detect we get in this state.
But I'm not sure it's possible, because we might not have received a result
yet that tells we are in a state not allowed (in a COPY).

Observation: maybe EnterpriseDB has resources enough to help us debugging
and fixing this issue, or maybe even implement async copy?

-- Daniele


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Copy command hangs in poll() function
  2018-10-04 05:35 Copy command hangs in poll() function Akshay Joshi <[email protected]>
  2018-10-04 10:26 ` Re: Copy command hangs in poll() function Daniele Varrazzo <[email protected]>
@ 2018-10-04 10:29   ` Daniele Varrazzo <[email protected]>
  1 sibling, 0 replies; 4+ messages in thread

From: Daniele Varrazzo @ 2018-10-04 10:29 UTC (permalink / raw)
  To: [email protected]; +Cc: psycopg

On Thu, Oct 4, 2018 at 11:26 AM Daniele Varrazzo
<[email protected]> wrote:

> Uhm, I see:

Issue https://github.com/psycopg/psycopg2/issues/781 opened.

-- Daniele




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Copy command hangs in poll() function
  2018-10-04 05:35 Copy command hangs in poll() function Akshay Joshi <[email protected]>
  2018-10-04 10:26 ` Re: Copy command hangs in poll() function Daniele Varrazzo <[email protected]>
@ 2018-10-04 10:33   ` Federico Di Gregorio <[email protected]>
  1 sibling, 0 replies; 4+ messages in thread

From: Federico Di Gregorio @ 2018-10-04 10:33 UTC (permalink / raw)
  To: Daniele Varrazzo <[email protected]>; [email protected]; +Cc: psycopg

On 10/04/2018 12:26 PM, Daniele Varrazzo wrote:
> On Thu, Oct 4, 2018 at 6:35 AM Akshay Joshi 
> <[email protected] <mailto:[email protected]>> 
> wrote:
> 
>     Hello
> 
>     As per documentation http://initd.org/psycopg/docs/advanced.html
>     <http://initd.org/psycopg/docs/advanced.html> Copy commands are not
>     supported in asynchronous mode, but this will be probably
>     implemented in a future release. In pgAdmin4 (open source) we have
>     used async connection to run the SQL query on PostgreSQL database
>     and uses poll() function to poll the results. When user runs any
>     *COPY *command application hangs at poll() function. 
> 
> 
>     If copy command not supported then at least it should not hang the
>     application. poll() function should return the proper error message.
> 
>     Can you please provide that fix until support for copy command won't
>     come.
> 
> 
> Uhm, I see:
> 
>      In [2]: cnn = psycopg2.connect("")
>      In [3]: cur = cnn.cursor()
>      In [4]: cur.execute("copy (select 1 as x) to stdout")
>      
> ---------------------------------------------------------------------------
>      ProgrammingError                          Traceback (most recent 
> call last)
>      <ipython-input-4-62e3af3d121e> in <module>()
>      ----> 1 cur.execute("copy (select 1 as x) to stdout")
>      ProgrammingError: can't execute COPY TO: use the copy_to() method 
> instead
> 
> but:
> 
>      In [6]: cnn = psycopg2.connect("", async=True)
>      In [7]: cnn.poll()
>      Out[7]: 2
>      In [8]: cnn.poll()
>      Out[8]: 1
>      In [9]: cnn.poll()
>      Out[9]: 0
> 
>      In [12]: cur.execute("copy (select 1 as x) to stdout")
>      In [14]: cnn.poll()
>      ^C -- hung
> 
> So yes, I'll take a look if there is a way to detect we get in this 
> state. But I'm not sure it's possible, because we might not have 
> received a result yet that tells we are in a state not allowed (in a COPY).
> 
> Observation: maybe EnterpriseDB has resources enough to help us 
> debugging and fixing this issue, or maybe even implement async copy?

Also, let me add that if the only way to detect the situation is by 
analyzing the query, we'll never do that.

Also, IMHO, it is perfectly fine that a sequence of operations that is 
documented as "not working" hangs - it is not something you can do by 
error: you're ignoring the documentation.

federico

-- 
Federico Di Gregorio                         [email protected]
DNDG srl                                                  http://dndg.it
    I filosofi son come i sociologi: il mondo non lo capiscono. -- A.R.M.




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2018-10-04 10:33 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-10-04 05:35 Copy command hangs in poll() function Akshay Joshi <[email protected]>
2018-10-04 10:26 ` Daniele Varrazzo <[email protected]>
2018-10-04 10:29   ` Daniele Varrazzo <[email protected]>
2018-10-04 10:33   ` Federico Di Gregorio <[email protected]>

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