Re: Added columns to pg_stat_activity

From: Neil Conway <neilc(at)samurai(dot)com>
To: Magnus Hagander <mha(at)sollentuna(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Added columns to pg_stat_activity
Date: 2005-05-09 01:13:51
Message-ID: 427EB94F.9040401@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Magnus Hagander wrote:
> I guess that's from not reading things carefully enough. I looked for
> where "backend pid" was transmitted, because I thought that would be a
> good place to put it.

On adapting the code to just send the client address in the BE start
message, I'm not actually sure this is the right way to go. The problem
is that stats messages are unordered -- so we might receive, say, an
activity message for a backend before we receive its BE startup message.
That means pg_stat_get_backend_client_addr() might be invoked for a
backend the stats collector knows about, but doesn't know its client
address. We could invent a sentinel value for this case and return SQL
NULL, but it seems quite ugly (since the backend entry struct stores
SockAddr, not SockAddr *)-- simpler to just send the client address with
every message, I guess.

> Which might bring up the question, why are things like the backend
> pid sent in msghdr and not in bestart?

If not for the situation outlined above, we could move at least m_userid
out of the message header.

> That said, I'm not sure that the startup time specifically is sensitive,
> no. No real rason to hide that, but I'm not sure I buy the argument
> "considering since it's available via ps(1)" ;-)

Yeah, that's true, the ps(1) argument is invalid. May as well limit
access to it...

> I first did it with NULL,NULL, before I realised I could not make just
> that distinction. I guess in theory we could return 0.0.0.0 or
> 255.255.255.255 (similar for IPv6 of course, don't know offhand what
> that would be), btu that seems at least as ugly.
> Another way would be to have yet another column that would be "client
> address type", but given the options I think the current way is probably
> the least ugly.

Yeah, I agree -- I guess we should stick with the current convention.

-Neil

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-05-09 01:16:09 Re: lastval()
Previous Message Neil Conway 2005-05-09 01:01:18 Re: lastval()