Re: Async queries pretending to be synchronous

From: Khushboo Vashi <khushboo(dot)vashi(at)enterprisedb(dot)com>
To: Dave Page <dpage(at)pgadmin(dot)org>
Cc: pgadmin-hackers <pgadmin-hackers(at)postgresql(dot)org>
Subject: Re: Async queries pretending to be synchronous
Date: 2019-03-04 05:43:21
Message-ID: CAFOhELcVx8ojo1__Th-u8a4OQdoR6ccBWHHK4SWcyOh0s30_uw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

On Fri, Mar 1, 2019 at 10:01 PM Dave Page <dpage(at)pgadmin(dot)org> wrote:

> In investigating #3656 I found the initial problem to be that when running
> in a container, Gunicorn will kill the worker process if a thread doesn't
> respond for 30 seconds by default. I fixed that by making the timeout match
> the application session timeout, but it revealed another issue.
>
> Given the function below (from the ticket), if you open the query tool and
> run:
>
> SELECT 1; SELECT fails_after(30);
>
> the async query actually blocks for 30 seconds in the cur.execute() call
> in execute_async() in connection.py (line 968). This causes the entire app
> to hang (watch the dashboard requests pile up in pending state in the
> network tab of the browser dev tools).
>
> If you run just the second SELECT, it works as expected, as does running
> something like:
>
> SELECT 1; SELECT pg_sleep(30);
>
> Anyone have any idea what's going on?
>

Connection.poll() blocking the call here. ( connection.py - _wait_timeout
function line #1378 state = conn.poll() )
In the asynchronous connection, after executing the query, the conn.poll()
is being called to fetch the connection status.
It gives the status accordingly but in this case, it is blocking and not
giving the status.

> CREATE OR REPLACE FUNCTION fails_after(s integer)
> RETURNS text AS $$
> begin
> raise notice 'Entered';
> perform pg_sleep(s);
> raise '!!!';
> end;
> $$ LANGUAGE plpgsql;
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>

In response to

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Khushboo Vashi 2019-03-04 06:49:08 Re: Result grid rendering (was: Re: [pgAdmin4][Pattch] - RM #3673 - "Download as .csv" F8 does NOT work when one of joined files is a TEMPORARY file)
Previous Message Akshay Joshi 2019-03-02 07:57:35 Re: [pgAdmin4][Patch]: RM #3659 Query tool does not give warning when Auto Commit is turned on in an incomplete transaction