From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Borodin <amborodin(at)acm(dot)org>, amul sul <sulamul(at)gmail(dot)com> |
Subject: | Re: background sessions |
Date: | 2017-03-11 15:11:22 |
Message-ID: | CAFj8pRAfEkvHhq_Vt3vmLua_Rx-wSGb5xf6ARV_m6MeYYzDDZA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | Postg윈 토토SQL : |
2017-03-09 14:52 GMT+01:00 Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)
com>:
> On 3/8/17 14:22, Pavel Stehule wrote:
> > 1. will be background session process closed automatically when parent
> > process is closed?
>
> If the communications queue goes away the process will eventually die.
> This is similar to how a backend process will eventually die if the
> client goes away. Some more testing would be good here.
>
what means "eventually die"?
I called pg_sleep() in called subprocess.
Cancel, terminating parent process has not any effect. It is maybe
artificial test.
Little bit more realistic - waiting on table lock in background worker was
successful - and when parent was cancelled, then worker process was
destroyed too.
But when parent was terminated, then background worker process continued.
What is worse - the background worker had 100% CPU and I had to restart
notebook.
CREATE OR REPLACE FUNCTION public.foo()
RETURNS void
LANGUAGE plpythonu
AS $function$
with plpy.BackgroundSession() as a:
a.execute('update foo2 set a = 30')
a.execute('insert into foo2 values(10)')
$function$
postgres=#
I blocked foo2 in another session.
Regards
Pavel
>
> > 2. what timeouts are valid for this process - statement timeout, idle in
> > transaction timeout
>
> Those should work the same way. It's the same code that runs the
> queries, starts/stops transactions, etc.
>
> > I see significant risk on leaking sessions.
>
> Yeah, that's a valid concern. But I think it works ok.
>
> > There can be more doc and examples in plpython doc. It will be main
> > interface for this feature. Mainly about session processing.
>
> OK, I'll look into that again.
>
> --
> Peter Eisentraut http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-03-11 16:14:36 | Re: make check-world output |
Previous Message | Alvaro Herrera | 2017-03-11 13:24:46 | Re: make check-world output |