Re: PQexec() hangs on OOM

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Oleksandr Shulgin <oleksandr(dot)shulgin(at)zalando(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: PQexec() hangs on OOM
Date: 2015-09-12 08:56:51
Message-ID: CAA4eK1LCM0-oSYrQGTn+QAHkcW5ezWeMOLr=gV93RU-bmdrcOg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Sep 7, 2015 at 8:43 PM, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
wrote:

> On Mon, Sep 7, 2015 at 10:41 PM, Michael Paquier wrote:
> > In any case, attached are two patches:
> > - 0001 adds the OOM/failure handling for the BIND and COPY start
> > messages. This time the connection is not dropped. After a failure,
> > successive commands work as well, this addresses the previous issue
> > you reported.
> > - 0002 is a cleanup bonus, getRowDescriptions and getAnotherTuple have
> > some dead code that I think would be better removed, those are
> > remnants from a copy/paste from the similar code of protocol 2.
>
> And I forgot... Attached is a simple program to test BIND messages.
>

Still the same test fails for me.

postgres=# copy t1 from stdin;
out of memory
postgres=# copy t1 from stdin; --hangs here

It hangs in second statement, basically I think you can't change the
state to PGASYNC_BUSY on failure in case of copy in below code.

+ case PGASYNC_FATAL:
+ res = NULL;
+ /*
+ * Set the state back to BUSY, allowing parsing to proceed to
+ * consume messages coming from the server.
+ */
+ conn->asyncStatus = PGASYNC_BUSY;
+ break;

I think you need to keep the state as PGASYNC_COPY_*, so that
the pending data can be discarded.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Kapila 2015-09-12 09:11:06 Re: PQexec() hangs on OOM
Previous Message Bruce Momjian 2015-09-11 21:19:20 Re: BUG #13612: postgresql94-setup initdb in kickstart fails