Re: PQexec() hangs on OOM

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: hlinnaka(at)iki(dot)fi
Cc: 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-04-08 04:27:08
Message-ID: CAB7nPqTqJmUL_jmATPvXzfET9u6DFQxtvF2J74D7XO6QebyAEw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Apr 8, 2015 at 3:54 AM, Heikki Linnakangas wrote:
> On 04/07/2015 09:18 AM, Michael Paquier wrote:
>>
>> @@ -143,7 +143,11 @@ PQmakeEmptyPGresult(PGconn *conn, ExecStatusType
>> status)
>>
>> [...]
>
> That's not cool, because PQmakeEmptyPGresult may be called with conn ==
> NULL. In general, I'm a bit wary of changing PQmakeEmptyResult so that it
> sets the error message. Will have to check all the callers carefully to see
> if that would upset any of them. And it might be called by applications too.

Oops, my mistake. For a patch arguing to not change how libpq routines
behave this is bad, and contrary to what is mentioned in the docs as
well. I moved the error message into parseInput. I guess it makes more
sense there.

>> I have noticed as well that getCopyStart() in fe-protocol3.c needs to
>> be made a little bit smarter to make the difference between an OOM and
>> the not-enough-data type of problem.
>
> Yeah. getParamDescription still has the issue, with your patch.

Check.

>> This problem has a low probability to happen in the field, and no
>> people complained about that as well, so I think that patching only
>> HEAD is adapted.
>
>
> As long as the patch applies easily, I don't see much reason to not
> backpatch.

It applies cleanly down to 9.1. For 9.0 some minor tweaks are visibly needed.
In any case, take two is attached.
Regards,
--
Michael

Attachment Content-Type Size
0001-Improve-OOM-detection-of-parseInput-in-libpq.patch application/x-patch 21.0 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kevin Grittner 2015-04-08 12:32:20 Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)
Previous Message Timothy Garnett 2015-04-07 22:06:15 Re: BUG #12990: Missing pg_multixact/members files (appears to have wrapped, then truncated)