Skip site navigation (1) Skip section navigation (2)

backend now show status in 'ps'

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: hackers(at)postgreSQL(dot)org (PostgreSQL-development)
Subject: backend now show status in 'ps'
Date: 1998-06-04 18:32:53
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
I have completed a patch that shows the backend status on the 'ps' line
for each process:

24081  ./bin/postmaster -i -B 401 -d -o -F -S 1024
24089  /usr/local/postgres/./bin/postgres postgres test idle "" "" "" (postmaster)
24106  /usr/local/postgres/./bin/postgres postgres test SELECT "" "" "" (postmaster)

As you can see, the backend shows the user, database, and status, which
is either 'idle' or 'SELECT', 'UPDATE', 'VACUUM', etc.  Those "" are
there because I erased the other args.  "(postmaster)" is there because
that was the initial argv[0] value (we don't fork() anymore).

This will be useful, even if we go with further status features.  I am
interested in any other information I should be showing.  I believe
there is almost zero performance overhead in assigning/showing these
values, except that the strings should be valid during the entire time
it is assigned to argv.  We could almost display the row number as we
scan through a table.  Nifty feature.
This worked under BSDI, because if you say argv[1] = "test", and argc is
at least 2, it shows "test" in ps.  If argc is only one (they didn't use
any args), it will not show it, but I have added a nifty hack to the
postmaster to re-exec it so it is sure to have a least three args.  I
strip them off before processing.  You can see the patch in the patches

BSDI uses the kvm interface for ps, which allows 'ps' to grab the args
right out of the process's address space.  This is a nifty trick,
considering that 'ps' is run inside the address space of another
process.  I did not use the sendmail wack-the-environment method of
changing 'ps'-displayed args, because it is ugly code, and will probably
cause more problems than it is worth.  Hopefully most platforms will
allow this kind of assignment to be shown in 'ps'.

I have also removed some unused args to pg_exec_query().  Again, it is
in the patch posted.

Bruce Momjian                          |  830 Blythe Avenue
maillist(at)candle(dot)pha(dot)pa(dot)us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)


pgsql-hackers by date

Next:From: David GouldDate: 1998-06-04 18:35:38
Previous:From: David GouldDate: 1998-06-04 18:24:31

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group