From: | Christian Ullrich <chris(at)chrullrich(dot)net> |
---|---|
To: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Cc: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Subject: | Re: PostgreSQL in Windows console and Ctrl-C |
Date: | 2014-04-14 06:16:09 |
Message-ID: | 0edf912dadb14167b3244f811cc696b3@AMSPR06MB134.eurprd06.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
* From: Amit Kapila
> On Sun, Apr 13, 2014 at 5:59 PM, Christian Ullrich <chris(at)chrullrich(dot)net>
> wrote:
> > There are some possible solutions:
> >
> > - pg_ctl could set an environment variable (unless it has to be
> > compatible with postmasters from different versions, and it does
> > not, does it?).
>
> Do you mean to say use some existing environment variable?
> Introducing an environment variable to solve this issue or infact using
> some existing environ variable doesn't seem to be the best way to pass
> such information.
I meant creating a new one, yes. If, say, PGSQL_BACKGROUND_JOB was set,
the postmaster etc. would ignore the events.
> > pg_ctl creates a named job object, and the postmaster has all the
> > information it needs to reconstruct the name, so it can check if it is
> > running inside that pg_ctl-created job.
>
> We are already creating one job object, so may be that itself can be
> used, but not sure if Job Objects are supported on all platforms on which
> postgres works.
I mentioned that in my earlier message; we cannot rely on having that job
object around. If the OS does not support them (not much of a problem
nowadays, I think; anything anyone is going to run the version this will
first be released in on is going to) or, more likely, if something uses
PostgreSQL as "embedded" database and starts it in a job of their own,
pg_ctl will not create its job object.
There may also be software out there that a) runs PostgreSQL in this way,
b) uses the console events to stop it again, and c) does that with or
without a separate job object. Hence, deciding based on the existence of
a job object would break backward compatibility in this case, assuming
it exists in reality.
> If you have to pass such information, then why don't pass some special
> flag in command to CreateProcess()?
Because I wanted to avoid introducing a command line option to tell the
postmaster who started it. If we cannot look at job objects, and an
environment variable is not an option either, then this looks like the
best remaining solution.
I will create a patch based on this approach.
> There is always a chance that we ignore the CTRL+C for some app which
> we don't intend if we solve the problem by passing some info, as some
> other app could also do so, but I think it should not be a big problem.
No. In fact, if whatever starts the postmaster does pass that flag, we
can safely assume that it did not do so just for fun.
--
Christian
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2014-04-14 08:06:17 | Re: Race condition between PREPARE TRANSACTION and COMMIT PREPARED (was Re: Problem with txid_snapshot_in/out() functionality) |
Previous Message | Michael Paquier | 2014-04-14 05:03:04 | Re: Including replication slot data in base backups |