Re: Terminating a backend

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Terminating a backend
Date: 2008-03-10 18:22:20
Message-ID: 200803101822.m2AIMKv12176@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > Bruce Momjian wrote:
> >> When we get the termination signal, why can't we just set a global
> >> boolean, do a query cancel, and in the setjmp() code block check the
> >> global and exit --- at that stage we know we have released all locks and
> >> can exit cleanly.
>
> > Should I add this as a TODO? Seems so. Tom commented in the patches
> > queue that it will not work but I don't understand why.
>
> The problem with treating it like elog(ERROR) is that you're at the
> mercy of user-defined code as to whether you'll actually exit or not.
> UDFs can trap elog(ERROR).

I don't understand. I was never considering elog(ERROR).

Right now for cancel we have:

pqsignal(SIGINT, StatementCancelHandler);

I am suggesting we add a new fuction pg_terminate_backend() that does
everything just like cancel, but also sets a global variable that we
check in the loop where we look for the next command and if it is set,
we exit the backend.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2008-03-10 18:26:43 Re: Maximum statistics target
Previous Message Alvaro Herrera 2008-03-10 18:17:49 Re: Terminating a backend

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2008-03-10 19:13:35 Re: Terminating a backend
Previous Message Alvaro Herrera 2008-03-10 18:17:49 Re: Terminating a backend