Re: Stats collection on Windows

From: mark(at)mark(dot)mielke(dot)cc
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
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:03:31
Message-ID: 20060405100330.GA10082@mark.mielke.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Apr 05, 2006 at 09:58:54AM +0200, Martijn van Oosterhout wrote:
> On Wed, Apr 05, 2006 at 03:38:28AM -0400, mark(at)mark(dot)mielke(dot)cc wrote:
> > Once upon a time, when I played with this stuff (I mostly use UNIX, not
> > Windows), I concluded to myself that HANDLE was process-local, and that
> > it was allocated. Meaning - it won't be re-used until you CloseHandle().
> > It's best then, to think of HANDLE as a opaque object. Regardless, of
> > whether it is process-local or not, until you run CloseHandle(), it is
> > yours to keep, and it won't be re-used.
> HANDLE is process local? That is worse then, because then there's no
> guarentee that each process will see a different identifier.

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.

> The stats collector identifies processes by their process id, which
> they get using getpid(). If instead they used a handle for their own
> process (GetCurrentProcess() always returns -1, but you can apparently
> clone it to get a real handle), you have no idea whether that handle is
> unique amongst backends, because it's process local.

> The stats collector doesn't have any open handles for the backend, it's
> just a way for backends to identify themselves. It appears that process
> handles are not up to the task either...

> Do we have a plan C?

Sure. Serial. Allocate on process start.

Or, back to another topic from months ago - UUID generation... :-)

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.

Cheers,
mark

--
mark(at)mielke(dot)cc / markm(at)ncf(dot)ca / markm(at)nortel(dot)com __________________________
. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder
|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ |
| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada

One ring to rule them all, one ring to find them, one ring to bring them all
and in the darkness bind them...

http://mark.mielke.cc/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message mark 2006-04-05 10:06:28 Re: Stats collection on Windows
Previous Message Magnus Hagander 2006-04-05 08:31:37 Re: Stats collection on Windows