Re: PQexec() hangs on OOM
От | Michael Paquier |
---|---|
Тема | Re: PQexec() hangs on OOM |
Дата | |
Msg-id | CAB7nPqSr2rEe0pHTkbCeVDpubM7jSZs-V5HvF-3Yhgexrz1z2Q@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: PQexec() hangs on OOM (Amit Kapila <amit.kapila16@gmail.com>) |
Список | pgsql-bugs |
On Sat, Sep 12, 2015 at 5:56 PM, Amit Kapila <amit.kapila16@gmail.com> wrote: > On Mon, Sep 7, 2015 at 8:43 PM, Michael Paquier <michael.paquier@gmail.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. Yes right. And my patch was as well broken with PGRES_COPY_BOTH. If the replication protocol expected to wait for some data, this would have frozen as well as it's a two-way data exchange in this case. -- Michael
В списке pgsql-bugs по дате отправления: