Re: windows doesn't notice backend death

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: windows doesn't notice backend death
Date: 2009-05-04 08:59:50
Message-ID: 49FEAE86.8080300@hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>> Well, I can tell you that it is getting an exit code of 1, which is why
>> the postmaster isn't restarting.
>
> Blech. Count on Windows to find a way to break things.

Yup. A quick search gives this:
http://support.microsoft.com/kb/155075

which clearly states that task manager simply uses TerminateProcess().
And it's probably hard-coded with an exit code.

Which really means this can't have worked, and my memory was wrong.

I still claim it works when the process actually *crashes* though -
since that will give you one of those funky huge exit numbers.

>> That raises two questions in my mind. First, is that the behaviour we
>> expect when we kill the backend this way? And second, why is it still
>> showing up in the output of pg_stat_activity?
>
> Well, if the process is being hard-killed without an opportunity to run
> through proc_exit(), then yes it is going to still show up in
> pg_stat_activity. It's pgstat_beshutdown_hook that removes that entry.

That's certainly what task manager does. TerminateProcess() just stops
all threads and removes the process. No chance for atexit() stuff to run.

> The problem here is that we need to be able to distinguish a task
> manager kill from a voluntary exit(1). Have M$ really been stupid
> enough to make an external kill look just like an exit() call?

It certainly looks that way. It probably goes back to the "use threads,
not processes, on this platform" design...

//Magnus

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2009-05-04 09:03:27 Re: windows doesn't notice backend death
Previous Message Greg Stark 2009-05-04 08:57:47 Re: high shared buffer and swap