pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: TAKATSUKA Haruka <harukat@sraoss.co.jp>
To: pgsql-odbc@postgresql.org
Subject: Re: Silent MALLOC/REALLOC error
Date: Fri, 16 Mar 2018 10:44:36 +0900
Message-ID: <20180316104436.3f278f45dcd90ffa7028007c@sraoss.co.jp> (raw)
In-Reply-To: <7153825a-4b01-cb09-1b21-147470a1b04a@dream.email.ne.jp>
References: <20180227183315.ba3f4b32cacd40549a4bc035@sraoss.co.jp>
	<7153825a-4b01-cb09-1b21-147470a1b04a@dream.email.ne.jp>

Hello Inoue-san,

Thanks for your psqlodbc fix.

I did test with the patch that atteched in the following mail.
It works fine.
When QR_REALLOC_return_with_error return FALSE, executing API
correctly results in failure. 

These are logs of my "out of memory" test.

psqlodbc log:
------------
[0.376]PQsendQuery: 00000000003F5FA0 'SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9 FROM t42 LIMIT 100000'
[0.387]	nFields: 9
[0.390]	fieldname='col1', adtid=25, adtsize=-1, atttypmod=-1 (rel,att)=(26258,1)
[0.392]	fieldname='col2', adtid=25, adtsize=-1, atttypmod=-1 (rel,att)=(26258,2)
snip
[1.426]	 'aaa'(3) 'aaa'(3) 'aaa'(3) 'aaa'(3) 'aaa'(3) 'aaa'(3) 'aaa'(3) 'aaa'(3) 'aaa'(3)
[1.429]QR_REALLOC_error
[1.431]	Getting result from PGresult failed

mylog:
------
[9820-1.520] environ.c[ER_ReturnError]259: 	     szSqlState = 'S1001',len=63, szError='(null)'
[9820-1.521] pgapi30.c[PGAPI_GetDiagField]390: leaving 0
[9820-1.521]odbcapi30w[SQLGetDiagFieldW]364: Entering Handle=(3,0000000000406AB0) Rec=2 Id=4 info=(00000000002BDC20,12)
[9820-1.523] pgapi30.c[PGAPI_GetDiagField]92: entering rec=2
[9820-1.523] environ.c[ER_ReturnError]202: entering status = 4, msg = #Out of memory while reading tuples.;
memory allocation error???#
[9820-1.525] pgapi30.c[PGAPI_GetDiagField]390: leaving 100
[9820-6.945]psqlodbc.c[DllMain]137: DETACHING PSQLODBC35W.DLL


Thanks,
Haruka Takatsuka


On Mon, 12 Mar 2018 16:06:50 +0900
"Inoue, Hiroshi" <h-inoue@dream.email.ne.jp> wrote:

> Hi TAKATSUKA-san,
> 
> sorry for the late reply.
> 
> On 2018/02/27 18:33, TAKATSUKA Haruka wrote:
> > Hello, psqlODBC team.
> >
> > When we fetch large data via psqlodbc, we sometimes fail to
> > get all rows completely without any API's error responses;
> > SQLExecDirect returns SQL_SUCCESS and SQLFetch returns just SQL_NODATA.
> > But there are QR_REALLOC_error reported in mylog at that time.
> >
> > I reproduced it by tweaking QR_REALLOC_return_with_error macro
> > to intentionally fail to allocate memory frequently.
> >
> > I propose the patch attached.
> > It makes the code in CC_send_query_append() go out the while-loop immediately
> > after CC_from_PGresult() at the case PORES_BAD_RESPONSE, PORES_FATAL_ERROR or PORES_NO_MEMORY_ERROR.
> 
> Thanks for the bug report.
> By applying your patch, subsequent queries after ALLOC errors are 
> rejected unfortunately
> with the error message 'another command is already in progress'.
> 
> I propose the patch attached. Does the patch work well in your test cases?
> 
> regards,
> Hiroshi Inoue





view thread (3+ messages)

Message-ID: <20180316104436.3f278f45dcd90ffa7028007c@sraoss.co.jp>
Permalink:  ../20180316104436.3f278f45dcd90ffa7028007c@sraoss.co.jp/
Also on:    postgresql.org/message-id/20180316104436.3f278f45dcd90ffa7028007c@sraoss.co.jp

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: harukat@sraoss.co.jp
  Subject: Re: Silent MALLOC/REALLOC error
  In-Reply-To: <20180316104436.3f278f45dcd90ffa7028007c@sraoss.co.jp>
  References: <20180227183315.ba3f4b32cacd40549a4bc035@sraoss.co.jp> <7153825a-4b01-cb09-1b21-147470a1b04a@dream.email.ne.jp> <20180316104436.3f278f45dcd90ffa7028007c@sraoss.co.jp>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox