Re: PQexec() hangs on OOM

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(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-08 11:48:38
Message-ID: CAB7nPqQzyE8=8_NyTAJgJ05WLRfxOe-8CihsLQtomr9nExLkQw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Sep 8, 2015 at 12:13 AM, 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.

And it occurred to me after sleeping on it that what I sent earlier is
not enough: in the case where the server has sent only a partial
message, we should not move into an error code path, but simply get
back into the loop of pqGetResult and wait for additional input from
the server. Attached are patches to fix that.
Regards,
--
Michael

Attachment Content-Type Size
0001-Prevent-COPY-start-and-BIND-to-freeze-in-libpq-on-OO.patch binary/octet-stream 11.3 KB
0002-Remove-dead-code-of-libpq-protocol-3.patch binary/octet-stream 4.8 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Fujii Masao 2015-09-08 17:02:10 Re: GRANT USAGE ON SEQUENCE missing from psql command completion
Previous Message Michael Paquier 2015-09-07 15:13:15 Re: PQexec() hangs on OOM