Re: How many postmasters should be running?

From: "Stock, Stuart" <Stuart(dot)Stock(at)DrKW(dot)com>
To: 'Tom Lane' <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Michael Fuhr <mike(at)fuhr(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How many postmasters should be running?
Date: 2006-02-28 18:06:20
Message-ID: 6F47643287F3A34B8EE40B91602974DB01631754@ibnycce153.us.ad.drkw.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Here's ps output, as you can see there is a second postmaster (pid 17303)
that is a child of the original postmaster (pid 28317):

prod 28317 1 0 Feb25 ? 00:00:02
/mnt/prod/postgresql-8.1.2/bin/postmaster -i
prod 28321 28317 0 Feb25 ? 00:00:11 postgres: logger process
prod 28323 28317 0 Feb25 ? 00:02:32 postgres: writer process
prod 28324 28317 0 Feb25 ? 00:00:00 postgres: archiver process
prod 28325 28317 0 Feb25 ? 00:00:05 postgres: stats buffer process
prod 28326 28325 0 Feb25 ? 00:00:11 postgres: stats collector process
prod 13571 28317 0 09:19 ? 00:00:00 postgres: pos abdb host.x.y.net(33623)
idle
prod 16214 28317 5 10:05 ? 00:00:46 postgres: pos abdb 10.123.45.79(4232)
idle
prod 16268 28317 0 10:05 ? 00:00:00 postgres: pos abdb 10.123.45.79(4237)
idle
prod 16328 28317 0 10:06 ? 00:00:05 postgres: pos xyzdb 10.123.45.79(4245)
idle
prod 17303 28317 0 10:19 ? 00:00:00
/mnt/prod/postgresql-8.1.2/bin/postmaster -i

Viewing this as a tree (ps aefx) makes it a little more obvious:

28317 ? S 0:02 /mnt/prod/postgresql-8.1.2/bin/postmaster -i HOSTNAME=host1
TERM=xterm SHE
28321 ? S 0:11 \_ postgres: logger process
28323 ? S 2:32 \_ postgres: writer process
28324 ? S 0:00 \_ postgres: archiver process
28325 ? S 0:05 \_ postgres: stats buffer process
28326 ? S 0:11 | \_ postgres: stats collector process
13571 ? S 0:00 \_ postgres: pos abdb host.x.y.net(33623) idle
16214 ? S 0:46 \_ postgres: pos abdb 10.123.45.79(4232) idle
16268 ? S 0:00 \_ postgres: pos abdb 10.123.45.79(4237) idle
16328 ? S 0:05 \_ postgres: pos xyzdb 10.123.45.79(4245) idle
17327 ? S 0:00 \_ /mnt/prod/postgresql-8.1.2/bin/postmaster -i
HOSTNAME=host1 TERM=xterm

Wait a sec...looking at the above I just noticed that the process id of the
second postmaster in the first 'ps' output listing is different from the pid
in the tree listing. At the time this second postmaster appeared, there were
a lot of connections to the database being attempted (and rejected due to
pg_hba.conf configuration).

Perhaps I'm just seeing a moment-in-time snapshot of the postmaster
fork()'ing to handle these connections, but because they were rejected, it
never had time to rename itself to 'postgres'?

Stuart

-----Original Message-----
From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Monday, February 27, 2006 10:09 PM
To: Michael Fuhr
Cc: Stock, Stuart; pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] How many postmasters should be running?

Michael Fuhr <mike(at)fuhr(dot)org> writes:
> On Mon, Feb 27, 2006 at 09:05:51PM -0500, Stock, Stuart wrote:
>> A few minutes ago, we were surprised to find a second postmaster process
>> running on our database machine as a child of the original postmaster.

> Each connection causes the postmaster to fork a new process to
> handle that connection.

Also, all postmaster child processes will properly identify themselves
as long as you are using the appropriate ps options. (Depending on your
OS, the default ps output format might just list them all as "postmaster".)
Try something like "ps auxww | grep postgres" if using Linux.

regards, tom lane

If you have received this e-mail in error or wish to read our e-mail disclaimer statement and monitoring policy, please refer to http://www.drkw.com/disc/email/ or contact the sender.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-02-28 18:14:23 Re: How many postmasters should be running?
Previous Message Roman Neuhauser 2006-02-28 16:43:13 Re: majordomo unmaintained, postmaster emails ignored?