Re: JDBC executeBatch() hangs without error

From: "Vinay S (vinas)" <vinas(at)cisco(dot)com>
To: Dave Cramer <davecramer(at)gmail(dot)com>
Cc: List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: JDBC executeBatch() hangs without error
Date: 2013-09-26 17:32:33
Message-ID: 3D2CB312427D204EAC2BCEB9771CB1951E3F5126@xmb-aln-x01.cisco.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Let me also add that there is inconsistency there too. For eg., this same program has been working on Win 7 on 1 system until yesterday, it just decided it wouldn't :)

On the other Win 7, it hasn't been working since Day 1.

Where do I look?

- Vinay

From: Dave Cramer [mailto:davecramer(at)gmail(dot)com]
Sent: Thursday, September 26, 2013 10:59 PM
To: Vinay S (vinas)
Cc: List
Subject: Re: [JDBC] JDBC executeBatch() hangs without error

So this is only win7 ??? sounds pretty strange as this is through tcp, and a java vm. Must be something in the O/S blocking it.

Dave Cramer

On Thu, Sep 26, 2013 at 1:04 PM, Vinay S (vinas) <vinas(at)cisco(dot)com<mailto:vinas(at)cisco(dot)com>> wrote:
Hi Dave,
Thanks for the reply.

I did try debugging a bit more and have more info to share. Short answer, executeBatch() simply hangs for even 1 row.

I updated my post to reflect the debugging info here http://postgresql.1045698.n5.nabble.com/JDBC-executeBatch-hangs-without-error-td5772465.html

Gist of that debugging info is that

Program hangs exactly at
int read = wrapped.read(buffer, endIndex, canFit);

in VisibleBufferedInputStream.java

executeBatch() works fine on Win2008, whereas hangs on Win7 (different instance of Win 7 too)

Any help here would be great.

Thanks.

- Vinay

From: davecramer(at)gmail(dot)com<mailto:davecramer(at)gmail(dot)com> [mailto:davecramer(at)gmail(dot)com<mailto:davecramer(at)gmail(dot)com>] On Behalf Of Dave Cramer
Sent: Thursday, September 26, 2013 9:55 PM
To: Vinay S (vinas)
Cc: List
Subject: Re: [JDBC] JDBC executeBatch() hangs without error

I can't really say where the issue is.

Can you try using batches of less than 254 to see if that works ?

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

On Thu, Sep 26, 2013 at 9:17 AM, vinay_s <vinas(at)cisco(dot)com<mailto:vinas(at)cisco(dot)com>> wrote:
Postgres Version Used : 9.1.9 - 64 bit
JDBC Driver used : PostgreSQL 9.2 JDBC4 (build 1003)
JDK used : 1.6u45 - 64 bit
OS: Windows 7 - 64 bit

I have simple insert query using which I'm trying to import around 20,000
rows by splitting them into 10 batches of 2000 each

insert into Datapool (datapool_id,fk_template_column,fk_branch,value)
values(?,?,?,?)

is the JDBC prepared statement.

Every 2000 rows, I add as a batch using

stmt.addBatch();

and and then call

stmt.executeBatch();

Program hangs at executeBatch() indefinitely and does not terminate.

To debug further,
- I took the source for the JDBC Driver
- Enabled log_statement ='all' in postgresql.conf(restarted the service of
course)
- Appended ?loglevel=2 in the JDBC Connection URL

I execute the program and saw that the executeBatch of 2000 entries just
halts after 254 insert queries are bound.

Output from the postgres log shows only one insert query
---------------------------------------------------------
2013-09-26 18:19:16 IST LOG: execute S_1: insert into Datapool
(datapool_id,fk_template_column,fk_branch,value) values($1,$2,$3,$4)
2013-09-26 18:19:16 IST DETAIL: parameters: $1 = '32056', $2 = '2215', $3 =
'21', $4 = 'col1'
----------------------------------------------------------

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kevin Wooten 2013-09-26 17:40:49 Re: JDBC executeBatch() hangs without error
Previous Message vinay_s 2013-09-26 13:17:21 JDBC executeBatch() hangs without error