Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eweQF-0000Ny-9t for pgsql-odbc@arkaria.postgresql.org; Fri, 16 Mar 2018 01:44:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eweQD-0003Qy-1f for pgsql-odbc@arkaria.postgresql.org; Fri, 16 Mar 2018 01:44:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eweQC-0003Qk-Ry for pgsql-odbc@lists.postgresql.org; Fri, 16 Mar 2018 01:44:40 +0000 Received: from sraihb2.sra.co.jp ([202.32.10.6]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eweQ8-00033n-5p for pgsql-odbc@postgresql.org; Fri, 16 Mar 2018 01:44:39 +0000 Received: from srascf.sra.co.jp (srascf [133.137.8.80]) by sraihb2.sra.co.jp (Postfix) with ESMTP id DC0822A15F1 for ; Fri, 16 Mar 2018 10:44:33 +0900 (JST) Received: from srascb.sra.co.jp (unknown [133.137.8.65]) by srascf.sra.co.jp with smtp id 7114_1517_555aa8d7_6b93_4554_952b_26608f0955be; Fri, 16 Mar 2018 10:44:32 +0900 Received: from sranhm.sra.co.jp (osspc25 [133.137.174.97]) by srascb.sra.co.jp (Postfix) with ESMTP id C812F2D6942 for ; Fri, 16 Mar 2018 10:44:33 +0900 (JST) Received: from harukat-PC (dhcp-175-181.sra.co.jp [133.137.175.181]) by sranhm.sra.co.jp (Postfix) with SMTP id ABA0EA141E for ; Fri, 16 Mar 2018 10:44:33 +0900 (JST) Date: Fri, 16 Mar 2018 10:44:36 +0900 From: TAKATSUKA Haruka To: pgsql-odbc@postgresql.org Subject: Re: Silent MALLOC/REALLOC error Message-Id: <20180316104436.3f278f45dcd90ffa7028007c@sraoss.co.jp> 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> Organization: SRA OSS, Inc. X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.23; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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" 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