Re: Out of memory error causes Abort, Abort tries to allocate memory - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: Out of memory error causes Abort, Abort tries to allocate memory
Date
Msg-id 20061025192049.GA9340@alvh.no-ip.org
Whole thread Raw
In response to Out of memory error causes Abort, Abort tries to allocate memory  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: Out of memory error causes Abort, Abort tries to
Re: Out of memory error causes Abort, Abort tries to allocate memory
List pgsql-bugs
Jeff Davis wrote:
> I found the root cause of the bug I reported at:
>
> http://archives.postgresql.org/pgsql-bugs/2006-10/msg00211.php
>
> What happens is this:
> * Out of memory condition causes an ERROR
> * ERROR triggers an AbortTransaction()
> * AbortTransaction() calls RecordTransactionAbort()
> * RecordTransactionAbort calls smgrGetPendingDeletes()
> * smgrGetPendingDeletes() calls palloc()
> * palloc() fails, resulting in ERROR, causing infinite recursion
> * elog.c detects infinite recursion, and elevates it to PANIC
>
> I'm not sure how easy this is to fix, but I asked on IRC and got some
> agreement that this is a bug.

Hmm, maybe we could have AbortTransaction switch to ErrorContext, which
has some preallocated space, before calling RecordTransactionAbort (or
maybe have RecordTransactionAbort itself do it).

Problem is, what happens if ErrorContext is filled up by doing this?  At
that point we will be severely fscked up, and you probably won't get the
PANIC either.  (Maybe it doesn't happen in this particular case, but
seems a real risk.)

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

pgsql-bugs by date:

Previous
From: Jeff Davis
Date:
Subject: Out of memory error causes Abort, Abort tries to allocate memory
Next
From: Jeff Davis
Date:
Subject: Re: Out of memory error causes Abort, Abort tries to