RE: [bug fix] Produce a crash dump before main() on Windows

From: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>
To: 'Craig Ringer' <craig(at)2ndquadrant(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: [bug fix] Produce a crash dump before main() on Windows
Date: 2018-02-26 04:06:48
Message-ID: 0A3221C70F24FB45833433255569204D1F8D6B1B@G01JPEXMBYT05
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers

From: Craig Ringer [mailto:craig(at)2ndquadrant(dot)com]
> The patch proposed here means that early crashes will invoke WER. If we're
> going to allow WER we should probably just do so unconditionally.
>
> I'd be in favour of leaving WER on when we find out we're in a noninteractive
> service too, but that'd be a separate patch for pg11+ only.

As for PG11+, I agree that we want to always leave WER on. That is, call SetErrorMode(SEM_FAILCRITICALERRORS) but not specify SEM_NOGPFAULTERRORBOX. The problem with the current specification of PostgreSQL is that the user can only get crash dumps in a fixed folder $PGDATA\crashdumps. That location is bad because the crash dumps will be backed up together with the database cluster without the user noticing it. What's worse, the crash dumps are large. With WER, the user can control the location and size of crash dumps.

> I suggest changing this to a command line flag or environment variable test
> that suppresses Pg's default disabling of WER. A GUC probably doesn't make
> sense; it's too niche, and too early.

As for the past major releases, it's burdensome for the user to have to specify a new flag or an environment variable when he has to get crash dumps to investigate a rare crash before main(). It's not necessary to disable WER for crashes after main() is called, because PG installs an exception handler at the beginning of main(), which works fine. So can we go with the current patch?

Another idea to add to the current patch is to move the call to SetErrorMode() to the below function, which is called first in main(). How about this?

void
pgwin32_install_crashdump_handler(void)
{
SetUnhandledExceptionFilter(crashDumpHandler);
}

Regards
Takayuki Tsunakawa

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2018-02-26 04:10:46 Re: [HACKERS] path toward faster partition pruning
Previous Message Ashutosh Bapat 2018-02-26 04:05:45 Re: PlaceHolderVars in pushed down child-join cause error