Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g80px-0006WA-CA for psycopg@arkaria.postgresql.org; Thu, 04 Oct 2018 10:26:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g80pv-00044v-QB for psycopg@arkaria.postgresql.org; Thu, 04 Oct 2018 10:26:27 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g80pv-00044o-Ft for psycopg@lists.postgresql.org; Thu, 04 Oct 2018 10:26:27 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1g80ps-0003ps-H3 for psycopg@postgresql.org; Thu, 04 Oct 2018 10:26:26 +0000 Received: by mail-lf1-x12d.google.com with SMTP id s10-v6so6363957lfc.9 for ; Thu, 04 Oct 2018 03:26:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xg3lgjz9T5MCbQM34yF2s9BLijBP9rg1HBnuufX+v80=; b=eBr7/Y2RrKRvjte6UdXu2YPRHz8B5IsB8b8grWK784ycBUVadYMz3yPxV/pFPFrDQF mUHZW28/1CklNoD+cyF1tEElDpiVIASbBUfko18nzsevdBuCtlSoJ4UCTfdEy2GX4yOt sVpC8w80nh35f8dtVxERUg2ld7BPOywsUOydYv70jAXWoUVAE9J/p9iODiXovnOMu/ox s2UMX7DaZvXL3aw6QpvEerhmteY0UE87Q7C5bcfNsaQa7A5c6+W9rpt78utvY4admj+h xWrLdV5CfYeop52Fg47UYYJ1dUcYSNxqZHbuojAMfqpJyOzceZ21mAmHhTXHUhHiL4as eu7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xg3lgjz9T5MCbQM34yF2s9BLijBP9rg1HBnuufX+v80=; b=QBbwKfaqDqP4xe4AUSdrR/yLzKZkRXhGKjeESuAlyj+WC9QqYOD6gSB1WTa9/z+Bmf nXnOArdXJmTMOBQvyAlVJuHtYOEcf03S+OrqV6MgwTCXEmBZBav6vfBW25oxZC/y08af oy8+bCILOHdjWYjJxH6aSy7way4fDMXKcRrDYHCGambGWr92iSk5NCidztV24sLVbffa VxDNlutAZPxigNn27orhCh/zQwneMA8G6vA1ohHtcgnC8ws59sBg1YVraC/o/wAZFjz3 9AL3V8XlAGGrniPaOblgcYuMruD3FBC0KmMPY9VNnhRyoIPDfdAbwk6k/b1jtMYZd9K1 D5yQ== X-Gm-Message-State: ABuFfoh0m2DGhT0AVUm7YVRzKesZM2Uh1QKK2ZZZHkAKFxIX09XpqNCf 35wuyEqRkN5IgfpteirSXpFqX/QbE7xrjBJoxtUuyLgc X-Google-Smtp-Source: ACcGV61Ph+UgskzxWcqvFGNhGrJX70XmM8V3aWWyKK7FDTdn9jBX+dl4Z2nSwnXiQYlpArggmVHA1fzCoqUmuG2o8BM= X-Received: by 2002:a19:7709:: with SMTP id s9-v6mr3480684lfc.84.1538648782460; Thu, 04 Oct 2018 03:26:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Daniele Varrazzo Date: Thu, 4 Oct 2018 11:26:11 +0100 Message-ID: Subject: Re: Copy command hangs in poll() function To: akshay.joshi@enterprisedb.com Cc: psycopg@postgresql.org Content-Type: multipart/alternative; boundary="0000000000001cda680577649623" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --0000000000001cda680577649623 Content-Type: text/plain; charset="UTF-8" On Thu, Oct 4, 2018 at 6:35 AM Akshay Joshi 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) in () ----> 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 --0000000000001cda680577649623 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Oct 4, 2018 at 6:35 AM Akshay = Joshi <akshay.joshi@ent= erprisedb.com> wrote:
Hello=C2=A0=

As per documentation http://initd.org/psycopg/docs/advanced.html=C2=A0Copy commands are no= t 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 app= lication hangs at poll() function.=C2=A0

If copy command not support= ed then at least it should not hang the application. poll() function should= return the proper error message.=C2=A0

Can you pl= ease provide that fix until support for copy command won't come.
<= /div>
=C2=A0
Uhm, I see:

=C2=A0 =C2=A0 In [2]: cnn =3D psycopg2.connect("= ;")
=C2=A0 =C2=A0 In [3]: cur =3D cnn.cursor()
=
=C2=A0 =C2=A0 In [4]: cur.execute("copy (select 1 as x) to stdout= ")
=C2=A0 =C2=A0 ---------------------------------------= ------------------------------------
=C2=A0 =C2=A0 ProgrammingErr= or=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 Traceback (most recent call last)
=C2=A0 =C2=A0= <ipython-input-4-62e3af3d121e> in <module>()
=C2=A0 = =C2=A0 ----> 1 cur.execute("copy (select 1 as x) to stdout")
=C2=A0 =C2=A0 ProgrammingError: can't execute COPY TO: use the= copy_to() method instead

but:
=C2=A0 =C2=A0 In [6]: cnn =3D psycopg2.connect(""= ;, async=3DTrue)
=C2=A0 =C2=A0 In [7]: cnn.poll()
=C2=A0 =C2=A0 Out[7]: 2
=C2=A0 =C2=A0 In [8]: cnn.poll()
=
=C2=A0 =C2=A0 Out[8]: 1
=C2=A0 =C2=A0 In [9]: cnn.poll()
=C2=A0 =C2=A0 Out[9]: 0

=C2=A0 =C2=A0 = In [12]: cur.execute("copy (select 1 as x) to stdout")
= =C2=A0 =C2=A0 In [14]: cnn.poll()
=C2=A0 =C2=A0 ^= 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 possib= le, 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 issu= e, or maybe even implement async copy?

-- Daniele<= /div>

--0000000000001cda680577649623--