pg_ctl idempotent option

Started by Peter Eisentrautabout 13 years ago38 messageshackers
Jump to latest
#1Peter Eisentraut
peter_e@gmx.net

Here is a patch to add an option -I/--idempotent to pg_ctl, the result
of which is that pg_ctl doesn't error on start or stop if the server is
already running or already stopped.

The previous discussion was at
</messages/by-id/1253165415.18853.32.camel@vanquo.pezone.net&gt;.

Attachments:

pg-ctl-idempotent.patchtext/x-patch; charset=UTF-8; name=pg-ctl-idempotent.patchDownload+50-11
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#1)
Re: pg_ctl idempotent option

Peter Eisentraut <peter_e@gmx.net> writes:

Here is a patch to add an option -I/--idempotent to pg_ctl, the result
of which is that pg_ctl doesn't error on start or stop if the server is
already running or already stopped.

Idempotent is a ten-dollar word. Can we find something that average
people wouldn't need to consult a dictionary to understand?

Also, should the option affect *only* the result code as you have it,
or should it also change the printed messages to reflect that the
case is considered expected?

Also it appears to me that the hunk at lines 812ff is changing the
default behavior, which is not what the patch is advertised to do.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Tom Lane (#2)
Re: pg_ctl idempotent option

Tom Lane wrote:

Peter Eisentraut <peter_e@gmx.net> writes:

Here is a patch to add an option -I/--idempotent to pg_ctl, the result
of which is that pg_ctl doesn't error on start or stop if the server is
already running or already stopped.

Idempotent is a ten-dollar word. Can we find something that average
people wouldn't need to consult a dictionary to understand?

--no-error perhaps?

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#3)
Re: pg_ctl idempotent option

Alvaro Herrera <alvherre@2ndquadrant.com> writes:

Tom Lane wrote:

Peter Eisentraut <peter_e@gmx.net> writes:

Here is a patch to add an option -I/--idempotent to pg_ctl, the result
of which is that pg_ctl doesn't error on start or stop if the server is
already running or already stopped.

Idempotent is a ten-dollar word. Can we find something that average
people wouldn't need to consult a dictionary to understand?

--no-error perhaps?

Meh, that's probably going too far in the direction of imprecision.
The point of this patch is that only very specific errors are
suppressed.

I don't have a better idea though. It'd be easier if there were
separate switches for the two cases, then you could call them
--ok-if-running and --ok-if-stopped. But that's not very workable,
if only because both would want the same single-letter abbreviation.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#5Thom Brown
thom@linux.com
In reply to: Alvaro Herrera (#3)
Re: pg_ctl idempotent option

On 14 January 2013 15:29, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:

Tom Lane wrote:

Peter Eisentraut <peter_e@gmx.net> writes:

Here is a patch to add an option -I/--idempotent to pg_ctl, the result
of which is that pg_ctl doesn't error on start or stop if the server is
already running or already stopped.

Idempotent is a ten-dollar word. Can we find something that average
people wouldn't need to consult a dictionary to understand?

--no-error perhaps?

Couldn't that be misconstrued as to suppress any type of error?

I personally can't think of something terse enough to put into a
descriptive long-word option that would adequately describe the change in
behaviour it provides.

--suppress-error-when-target-status-already-present ... bit too wordy. ;)

--
Thom

#6Boszormenyi Zoltan
zb@cybertec.at
In reply to: Tom Lane (#2)
Re: pg_ctl idempotent option

2013-01-14 16:22 keltezéssel, Tom Lane írta:

Peter Eisentraut <peter_e@gmx.net> writes:

Here is a patch to add an option -I/--idempotent to pg_ctl, the result
of which is that pg_ctl doesn't error on start or stop if the server is
already running or already stopped.

Idempotent is a ten-dollar word. Can we find something that average
people wouldn't need to consult a dictionary to understand?

--do-nothing-if-same-state?

Also, should the option affect *only* the result code as you have it,
or should it also change the printed messages to reflect that the
case is considered expected?

Also it appears to me that the hunk at lines 812ff is changing the
default behavior, which is not what the patch is advertised to do.

regards, tom lane

--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
http://www.postgresql.at/

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#7Dickson S. Guedes
listas@guedesoft.net
In reply to: Tom Lane (#4)
Re: pg_ctl idempotent option

2013/1/14 Tom Lane <tgl@sss.pgh.pa.us>:

Alvaro Herrera <alvherre@2ndquadrant.com> writes:

Tom Lane wrote:

Peter Eisentraut <peter_e@gmx.net> writes:

Here is a patch to add an option -I/--idempotent to pg_ctl, the result
of which is that pg_ctl doesn't error on start or stop if the server is
already running or already stopped.

Idempotent is a ten-dollar word. Can we find something that average
people wouldn't need to consult a dictionary to understand?

--no-error perhaps?

Meh, that's probably going too far in the direction of imprecision.
The point of this patch is that only very specific errors are
suppressed.

I don't have a better idea though. It'd be easier if there were
separate switches for the two cases, then you could call them
--ok-if-running and --ok-if-stopped. But that's not very workable,
if only because both would want the same single-letter abbreviation.

--ignore-status
--ignore-status-start
--ignore-status-stop

?

Regards
--
Dickson S. Guedes
mail/xmpp: guedes@guedesoft.net - skype: guediz
http://guedesoft.net - http://www.postgresql.org.br

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#8Vik Fearing
vik@postgresfriends.org
In reply to: Tom Lane (#2)
Re: pg_ctl idempotent option

On Mon, Jan 14, 2013 at 4:22 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Peter Eisentraut <peter_e@gmx.net> writes:

Here is a patch to add an option -I/--idempotent to pg_ctl, the result
of which is that pg_ctl doesn't error on start or stop if the server is
already running or already stopped.

Idempotent is a ten-dollar word. Can we find something that average
people wouldn't need to consult a dictionary to understand?

I disagree that we should dumb things down when the word means exactly what
we want and based on the rest of this thread is the only word or word
cluster that carries the desired meaning.

I vote to keep --idempotent.

Vik

#9Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Vik Fearing (#8)
Re: pg_ctl idempotent option

Vik Reykja escribió:

On Mon, Jan 14, 2013 at 4:22 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Peter Eisentraut <peter_e@gmx.net> writes:

Here is a patch to add an option -I/--idempotent to pg_ctl, the result
of which is that pg_ctl doesn't error on start or stop if the server is
already running or already stopped.

Idempotent is a ten-dollar word. Can we find something that average
people wouldn't need to consult a dictionary to understand?

I disagree that we should dumb things down when the word means exactly what
we want and based on the rest of this thread is the only word or word
cluster that carries the desired meaning.

I vote to keep --idempotent.

Yeah, after seeing the alternatives, I agree that it seems okay,
particularly given that the --help output explains the behavior in
dime-a-dozen words.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#10Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#9)
Re: pg_ctl idempotent option

Alvaro Herrera <alvherre@2ndquadrant.com> writes:

Vik Reykja escribi�:

On Mon, Jan 14, 2013 at 4:22 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Idempotent is a ten-dollar word. Can we find something that average
people wouldn't need to consult a dictionary to understand?

I disagree that we should dumb things down when the word means exactly what
we want and based on the rest of this thread is the only word or word
cluster that carries the desired meaning.

I'm not quite convinced that it means *exactly* what we want. The
dictionary definition, according to my laptop's dictionary, is "denoting
an element of a set that is unchanged in value when multiplied or
otherwise operated on by itself". I'm well aware that computer people
often use it to mean "an operation that doesn't change the system state
if the state is already what's wanted", but I think that's probably an
abuse of the mathematical usage. And in any case, I'm not sure that
non-hackers would immediately recognize the term, nor be enlightened by
their dictionaries. But ...

Yeah, after seeing the alternatives, I agree that it seems okay,

... I was only asking if we *could* find a better choice. Seems we
can't, so let's stick with this.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#11Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#2)
Re: pg_ctl idempotent option

On 1/14/13 10:22 AM, Tom Lane wrote:

Also it appears to me that the hunk at lines 812ff is changing the
default behavior, which is not what the patch is advertised to do.

True, I had forgotten to mention that.

Since it's already the behavior for start, another option would be to
just make it the default for stop as well and forget about the extra
options. I'm not sure whether there is a big use case for getting an
error code on stop if the server is already stopped.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#12Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#2)
Re: pg_ctl idempotent option

On 1/14/13 10:22 AM, Tom Lane wrote:

Idempotent is a ten-dollar word. Can we find something that average
people wouldn't need to consult a dictionary to understand?

My suggestion in the original thread was --oknodo, but people didn't
like that either.

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#13Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#11)
Re: pg_ctl idempotent option

Peter Eisentraut <peter_e@gmx.net> writes:

On 1/14/13 10:22 AM, Tom Lane wrote:

Also it appears to me that the hunk at lines 812ff is changing the
default behavior, which is not what the patch is advertised to do.

True, I had forgotten to mention that.

Since it's already the behavior for start, another option would be to
just make it the default for stop as well and forget about the extra
options. I'm not sure whether there is a big use case for getting an
error code on stop if the server is already stopped.

Actually, I seem to recall having had to hack Red Hat's initscript
because the LSB standard requires that stopping a not-running server
*not* be an error. So +1 for forgetting about the option entirely
and just making it idempotent all the time.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#14Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#10)
Re: pg_ctl idempotent option

On Tue, Jan 15, 2013 at 10:25:23AM -0500, Tom Lane wrote:

Alvaro Herrera <alvherre@2ndquadrant.com> writes:

Vik Reykja escribi�:

On Mon, Jan 14, 2013 at 4:22 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Idempotent is a ten-dollar word. Can we find something that average
people wouldn't need to consult a dictionary to understand?

I disagree that we should dumb things down when the word means exactly what
we want and based on the rest of this thread is the only word or word
cluster that carries the desired meaning.

I'm not quite convinced that it means *exactly* what we want. The
dictionary definition, according to my laptop's dictionary, is "denoting
an element of a set that is unchanged in value when multiplied or
otherwise operated on by itself". I'm well aware that computer people
often use it to mean "an operation that doesn't change the system state
if the state is already what's wanted", but I think that's probably an
abuse of the mathematical usage. And in any case, I'm not sure that
non-hackers would immediately recognize the term, nor be enlightened by
their dictionaries. But ...

I have heard idempotent used several times by our folks, and I didn't
know what it meant either. I figured it was a "strong item". ;-) I
just looked it up.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#15Bruce Momjian
bruce@momjian.us
In reply to: Peter Eisentraut (#12)
Re: pg_ctl idempotent option

On Tue, Jan 15, 2013 at 10:55:41AM -0500, Peter Eisentraut wrote:

On 1/14/13 10:22 AM, Tom Lane wrote:

Idempotent is a ten-dollar word. Can we find something that average
people wouldn't need to consult a dictionary to understand?

My suggestion in the original thread was --oknodo, but people didn't
like that either.

That's Japanese for idempotent. ;-) LOL

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#16Boszormenyi Zoltan
zb@cybertec.at
In reply to: Bruce Momjian (#14)
Re: pg_ctl idempotent option

2013-01-15 20:28 keltezéssel, Bruce Momjian írta:

On Tue, Jan 15, 2013 at 10:25:23AM -0500, Tom Lane wrote:

Alvaro Herrera <alvherre@2ndquadrant.com> writes:

Vik Reykja escribi�:

On Mon, Jan 14, 2013 at 4:22 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Idempotent is a ten-dollar word. Can we find something that average
people wouldn't need to consult a dictionary to understand?

I disagree that we should dumb things down when the word means exactly what
we want and based on the rest of this thread is the only word or word
cluster that carries the desired meaning.

I'm not quite convinced that it means *exactly* what we want. The
dictionary definition, according to my laptop's dictionary, is "denoting
an element of a set that is unchanged in value when multiplied or
otherwise operated on by itself". I'm well aware that computer people
often use it to mean "an operation that doesn't change the system state
if the state is already what's wanted", but I think that's probably an
abuse of the mathematical usage. And in any case, I'm not sure that
non-hackers would immediately recognize the term, nor be enlightened by
their dictionaries. But ...

I have heard idempotent used several times by our folks, and I didn't
know what it meant either. I figured it was a "strong item". ;-) I
just looked it up.

The math term used in Hungarian for idempotent is mirror translated
to "leave it in place". The term also has a slang usage for beating somebody up. ;-)

--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
http://www.postgresql.at/

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#17Josh Berkus
josh@agliodbs.com
In reply to: Peter Eisentraut (#12)
Re: pg_ctl idempotent option

On 01/15/2013 07:55 AM, Peter Eisentraut wrote:

On 1/14/13 10:22 AM, Tom Lane wrote:

Idempotent is a ten-dollar word. Can we find something that average
people wouldn't need to consult a dictionary to understand?

My suggestion in the original thread was --oknodo, but people didn't
like that either.

I'm pretty sure that Oknodo is an island in the Pacific. ;-)

I don't have a better idea for a name, though.

--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#18Michael Paquier
michael@paquier.xyz
In reply to: Bruce Momjian (#15)
Re: pg_ctl idempotent option

On Wed, Jan 16, 2013 at 4:29 AM, Bruce Momjian <bruce@momjian.us> wrote:

That's Japanese for idempotent. ;-) LOL

+1.
-- 
Michael Paquier
http://michael.otacoo.com
#19Phil Sorber
phil@omniti.com
In reply to: Tom Lane (#13)
Re: pg_ctl idempotent option

On Tue, Jan 15, 2013 at 11:06 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Peter Eisentraut <peter_e@gmx.net> writes:

On 1/14/13 10:22 AM, Tom Lane wrote:

Also it appears to me that the hunk at lines 812ff is changing the
default behavior, which is not what the patch is advertised to do.

True, I had forgotten to mention that.

Since it's already the behavior for start, another option would be to
just make it the default for stop as well and forget about the extra
options. I'm not sure whether there is a big use case for getting an
error code on stop if the server is already stopped.

Actually, I seem to recall having had to hack Red Hat's initscript
because the LSB standard requires that stopping a not-running server
*not* be an error. So +1 for forgetting about the option entirely
and just making it idempotent all the time.

+1

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#20Phil Sorber
phil@omniti.com
In reply to: Phil Sorber (#19)
Re: pg_ctl idempotent option

On Fri, Jan 18, 2013 at 8:48 PM, Phil Sorber <phil@omniti.com> wrote:

+1

Is there more work being done on this, or is the current patch ready to review?

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#21Ashutosh Bapat
ashutosh.bapat@enterprisedb.com
In reply to: Tom Lane (#13)
#22Bruce Momjian
bruce@momjian.us
In reply to: Ashutosh Bapat (#21)
#23Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Bruce Momjian (#22)
#24Bruce Momjian
bruce@momjian.us
In reply to: Heikki Linnakangas (#23)
#25Ashutosh Bapat
ashutosh.bapat@enterprisedb.com
In reply to: Bruce Momjian (#24)
#26Bruce Momjian
bruce@momjian.us
In reply to: Ashutosh Bapat (#25)
#27Simon Riggs
simon@2ndQuadrant.com
In reply to: Alvaro Herrera (#3)
#28Bruce Momjian
bruce@momjian.us
In reply to: Simon Riggs (#27)
#29Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#28)
#30Josh Berkus
josh@agliodbs.com
In reply to: Bruce Momjian (#29)
#31Ashutosh Bapat
ashutosh.bapat@enterprisedb.com
In reply to: Josh Berkus (#30)
#32Bruce Momjian
bruce@momjian.us
In reply to: Josh Berkus (#30)
#33Dimitri Fontaine
dimitri@2ndQuadrant.fr
In reply to: Bruce Momjian (#28)
#34Peter Eisentraut
peter_e@gmx.net
In reply to: Bruce Momjian (#28)
#35Bruce Momjian
bruce@momjian.us
In reply to: Peter Eisentraut (#34)
#36Josh Berkus
josh@agliodbs.com
In reply to: Bruce Momjian (#32)
#37Bruce Momjian
bruce@momjian.us
In reply to: Josh Berkus (#36)
#38Peter Eisentraut
peter_e@gmx.net
In reply to: Peter Eisentraut (#1)