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-10-16 02:00:51
Message-ID: CAB7nPqTNrw8LR1HD7ZLnOJjC1BP1Evw_EMAdGOrV+s-sBCrKtw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Oct 15, 2015 at 11:28 PM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> On Sun, Oct 11, 2015 at 6:31 PM, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
> wrote:
>>
>>
>> Yeah, this behavior is caused by this piece of code:
>> @@ -600,7 +601,9 @@ getRowDescriptions(PGconn *conn, int msgLength)
>> advance_and_error:
>> /* Discard unsaved result, if any */
>> if (result && result != conn->result)
>> PQclear(result);
>> An idea may be to check for conn->result->resultStatus !=
>> PGRES_FATAL_ERROR to concatenate correctly the error messages using
>> pqCatenateResultError. But just returning the first error encountered
>> as you mention would be more natural. So I updated the patch this way.
>>
>
> Minor comment:
> +getParamDescriptions(PGconn *conn, int msgLength)
> {
> ..
> +
> + /*
> + * Advance inStart to show that the copy related message has been
> + * processed.
> + */
> + conn->inStart = conn->inCursor;
> +
> ..
> }
>
> Reference to 'copy' in above comment seems to be wrong.

Oh, yes it wrong. This should refer to the "t" message.

> Other than that both the patches looks good to me, I will mark this as
> Ready for committer. Please see if you can update the patch soonish,
> if you find above comment valid.

Done. Thanks for the review!
--
Michael

Attachment Content-Type Size
0001-Fix-OOM-error-handling-in-COPY-protocol-of-libpq.patch text/x-diff 7.1 KB
0002-Fix-OOM-error-handling-in-BIND-protocol-of-libpq.patch text/x-diff 4.3 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message kseton 2015-10-16 15:08:26 Issue with database error: ERROR: invalid page header in block 579 of relation base/24067/12574
Previous Message Michael Paquier 2015-10-15 23:49:22 Re: BUG #13680: PostgreSQL backend process crashes on jsonb_object_agg() in plpgsql recursive function