From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | mark(at)mark(dot)mielke(dot)cc |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Qingqing Zhou <zhouqq(at)cs(dot)toronto(dot)edu>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Stats collection on Windows |
Date: | 2006-04-05 10:20:49 |
Message-ID: | 20060405102049.GC18401@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Apr 05, 2006 at 06:03:31AM -0400, mark(at)mark(dot)mielke(dot)cc wrote:
> It's no different from a file descriptor on UNIX.
>
> Neither UNIX nor Windows promise that a process identifier is valid
> beyond the life of the process. UNIX avoids it from happening, as it
> is necessary to avoid races with system calls such as kill(). Windows
> does not have this problem.
But consider, why is the process id there? (Amongst other reasons) so
that users can monitor pg_stat_activity and kill a backend that's out
of control. The equivalent to this in windows would be to.
1. Get HANDLE from the process ID.
2. TerminateProcess with that HANDLE.
Presumably users have a little GUI app that displays processes on the
system with the process ID so they can kill it. If a process ID is
quickly reused, they may end up killing the wrong one.
The race condition in this case involves the user and you can't solve
that programmatically. The non-reuse of pids is more for
user-friendlyness than anything else. The Window use of HANDLE doesn't
solve this problem at all.
> Sure. Serial. Allocate on process start.
>
> Or, back to another topic from months ago - UUID generation... :-)
Neither of which solve the "I'm a user and want to kill *that* backend"
problem. Because even on windows you'll have to get the process id,
convert it to a handle an kill it. Same race condition.
> Process identifier should not be used beyond the life of the process.
> As soon as wait() removes the process on UNIX, the process identifier
> is no longer valid, and could be reused. That the operating system tries
> to prevent problems by avoiding recycling isn't necessarily a good
> reason to exploit this capability.
Yeah, but it's very useful as a user. Consider this scenerio:
<process 1234 goes AWOL>
kill -INT 1234
<check if process still there>
kill -TERM 1234
<process still there, damn it!>
kill -9 1234
There gone. With no quick PID reuse I can be sure I won't kill the
wrong one. This is presumably why recent versions of windows don't reuse
pids quickly either... It for *users* not programs.
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.
From | Date | Subject | |
---|---|---|---|
Next Message | mark | 2006-04-05 10:35:34 | Re: Stats collection on Windows |
Previous Message | mark | 2006-04-05 10:06:28 | Re: Stats collection on Windows |