RE: [QUESTIONS] Identity Crisis
RE: [QUESTIONS] Identity Crisis
От:
"Jackson, DeJuan" <djackson@cpsgroup.com>
Дата:
Forwarded to HACKERS. > -----Original Message----- > From: Len Morgan [SMTP:len-morgan@xroadstx.com] > Sent: Saturday, May 02, 1998 8:21 AM > To: pgsql-questions@postgreSQL.org > Subject: [QUESTIONS] Identity Crisis > > I am running 6.3.2 at one of my client's sites that normally has 5 > users > connected. The problem I run into is that after a couple of days, I > end > up with as many as 12-15 postgres backends running on the server. The > users are encountering a bug in the code and then closing the window > and > restarting the program which never closes down the connection to the > back end. My question is this: Is there a way to identify on the line > which starts up the backends, which host is starting it? In other > words, if I do ps -ax on the server, can I have an ip address or host > name show up to let me know which host is connected to which backend? > This will not entirely solve my problem, but it will let me know which > user I need to educate about the proper way to work around the program > bug. Currently, I just kill the processes off one by one. If > somebody > calls me in the next five minutes or so, it was a "live" one. > Otherwise, nobody missed it. Also, if I send -SIGTERM to the > individual > backend's pid, will this properly clean up any memory that is in use? > > Thanks, > > len morgan > > -- > Official WWW Site: http://www.postgresql.org > Online Docs & FAQ: http://www.postgresql.org/docs > Searchable Lists: http://www.postgresql.org/mhonarc
Re: [HACKERS] RE: [QUESTIONS] Identity Crisis
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Len Morgan writes: >> My question is this: Is there a way to identify on the line >> which starts up the backends, which host is starting it? In other >> words, if I do ps -ax on the server, can I have an ip address or host >> name show up to let me know which host is connected to which backend? Hackers, if anyone does something with setting the backend process title, this seems like a good idea to me. However, a feature that may or may not show up in 6.4 is not going to help Len with his immediate problem. Len, I'd suggest a couple of things you can do today: 1. netstat on your server will show open TCP connections. Look for connections to port 5432 at your end. If you have a lot of users it might be hard to spot the culprit --- but I suspect that looking for the machine that shows a number of open connections, not just one, will do it. 2. If that doesn't work, but you can identify a backend process that's been laying around for awhile, you can use "lsof" to find out which network connection leads to that process. For example, I use ps to find that process 21309 is a backend, then: $ lsof -p 21309 COMMAND PID USER FD TYPE DEVICE SIZE/OFF INODE NAME postgres 21309 postgres 3u inet 0x0d2d1b00 0t0 TCP *:5432 (LISTEN) postgres 21309 postgres 5u inet 0x0d749000 0t302 TCP localhost:5432->localhost:2325 (ESTABLISHED) postgres 21309 postgres 6u inet 0x0d749000 0t302 TCP localhost:5432->localhost:2325 (ESTABLISHED) (lots of non-inet open files for this process snipped) So I see the client connected to this server is at port 2325 on localhost. lsof (list open files) might already be installed on your machine, if not see http://www-rcd.cc.purdue.edu/abe/. It's an invaluable tool for debugging all sorts of Unix problems, well worth having in your sysadmin kit. regards, tom lane