Re: Cluster name in ps output

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Thomas Munro <munro(at)ip9(dot)org>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Cluster name in ps output
Date: 2014-05-05 10:54:21
Message-ID: 20140505105421.GV12715@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2014-05-05 10:49:19 +0000, Thomas Munro wrote:
> On 5 May 2014 10:10, Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
>
> > Hi,
> >
> > On 2014-05-05 10:00:34 +0000, Thomas Munro wrote:
> > > When running more than one cluster I often find myself looking at
> > > the output of 'iotop' or other tools wondering which
> > > cluster's "wal receiver process" or "checkpointer process" etc
> > > I'm seeing.
> >
> > I wonder about that pretty regularly. To the point that I've a hacky
> > version of this locally. So +1 for me for the idea in general.
>
>
> Thanks! (Do you have a write up/diff somewhere showing the local
> modifications you're running?)

I've just hacked in the port into the ps display since that was
sufficient for my case.

> > > If cluster_name is not set, it defaults to the empty string and
> > > the ps output is unchanged. If it's set to 'foox' the ps output
> > > includes that string in square brackets:
> > >
> > > postgres: [foox] checkpointer process
> > > postgres: [foox] writer process
> > > postgres: [foox] wal writer process
> > > postgres: [foox] autovacuum launcher process
> > > postgres: [foox] stats collector process
> > > postgres: [foox] munro foodb [local] idle
> >
> > "postgres: [foox] ..." should rather be "postgres[foox]: ..." imo ;)
> >
> >
> Hah -- I agree, but on systems using setproctitle, the program name and ":
> " are provided already, so the end result would have to be different on
> those systems and I figured it should be the same everywhere if possible.

Fair point.

> > Aren't you potentially dereferencing a NULL pointer here?
> >
>
> Hmm -- I thought the GUC machinery would make sure cluster_name either
> pointed to the default I provided, an empty string, or a string read from
> the configuration file. Perhaps I need to go and read up on how GUCs work.

That's true - but I am not sure you can guarantee it's only called after
the GUC machinery has started up. Particularly on windows. I guess just
initializing the global variable to "" should do the trick.

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2014-05-05 11:58:30 Re: Cluster name in ps output
Previous Message Craig Ringer 2014-05-05 10:53:23 Re: Cluster name in ps output