pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
JDBC driver inserting into a table with Bytea type gets out of me mory error.
6+ messages / 3 participants
[nested] [flat]

* JDBC driver inserting into a table with Bytea type gets out of me mory error.
@ 2004-06-21 16:44  Sailer, Denis (YBUSA-CDR) <Denis.Sailer@Yellowbook.com>
  0 siblings, 2 replies; 6+ messages in thread

From: Sailer, Denis (YBUSA-CDR) @ 2004-06-21 16:44 UTC (permalink / raw)
  To: pgsql-jdbc

There was a posting in the mailing list archives that I can't find anymore.
The web site right now is presenting a list of items from a search in a
reasonable amount of time, but takes 5-10 minutes to retrieve the detail for
each one as they are clicked.  Rather frustrating.  

 

This person was getting out of memory conditions inserting rows when the
data in the bytea field was larger than approx.  1400 Kb.  This person had
posted a fix to the group that seemed to work for him.  The inserts were
coming from a java application using the JDBC driver.

 

I just tried the latest JDBC driver and the problem still exists.  We have
no plans to convert to using the large object interface.  This ties our code
to PostgreSQL and would go against our need to keep the code generic enough
to work against many different databases.

 

Is this issue acknowledged as a bug?

If yes, when is this issue going to be implemented in the code base?

If it is already fixed, what are the steps to implement the changes to my
7.4.2 installation?  Build my own JDBC driver?

 

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: JDBC driver inserting into a table with Bytea type gets
@ 2004-06-21 16:55  Dave Cramer <pg@fastcrypt.com>
  parent: Sailer, Denis (YBUSA-CDR) <Denis.Sailer@Yellowbook.com>
  1 sibling, 0 replies; 6+ messages in thread

From: Dave Cramer @ 2004-06-21 16:55 UTC (permalink / raw)
  To: Sailer, Denis (YBUSA-CDR) <Denis.Sailer@Yellowbook.com>; +Cc: pgsql-jdbc

Denis,

You will get better search results using google

just append site:postgresql.org to your search terms

Dave
On Mon, 2004-06-21 at 12:44, Sailer, Denis (YBUSA-CDR) wrote:
> There was a posting in the mailing list archives that I can't find
> anymore.  The web site right now is presenting a list of items from a
> search in a reasonable amount of time, but takes 5-10 minutes to
> retrieve the detail for each one as they are clicked.  Rather
> frustrating.  
> 
>  
> 
> This person was getting out of memory conditions inserting rows when
> the data in the bytea field was larger than approx.  1400 Kb.  This
> person had posted a fix to the group that seemed to work for him.  The
> inserts were coming from a java application using the JDBC driver.
> 
>  
> 
> I just tried the latest JDBC driver and the problem still exists.  We
> have no plans to convert to using the large object interface.  This
> ties our code to PostgreSQL and would go against our need to keep the
> code generic enough to work against many different databases.
> 
>  
> 
> Is this issue acknowledged as a bug?
> 
> If yes, when is this issue going to be implemented in the code base?
> 
> If it is already fixed, what are the steps to implement the changes to
> my 7.4.2 installation?  Build my own JDBC driver?
> 
>  
> 
> 
> !DSPAM:40d71228141141400527835!
-- 
Dave Cramer
519 939 0336
ICQ # 14675561




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: JDBC driver inserting into a table with Bytea type gets
@ 2004-06-21 19:02  Kris Jurka <books@ejurka.com>
  parent: Sailer, Denis (YBUSA-CDR) <Denis.Sailer@Yellowbook.com>
  1 sibling, 0 replies; 6+ messages in thread

From: Kris Jurka @ 2004-06-21 19:02 UTC (permalink / raw)
  To: Sailer, Denis (YBUSA-CDR) <Denis.Sailer@Yellowbook.com>; +Cc: pgsql-jdbc



On Mon, 21 Jun 2004, Sailer, Denis (YBUSA-CDR) wrote:

> This person was getting out of memory conditions inserting rows when the
> data in the bytea field was larger than approx.  1400 Kb.  This person had
> posted a fix to the group that seemed to work for him.  The inserts were
> coming from a java application using the JDBC driver.
> I just tried the latest JDBC driver and the problem still exists.
> Is this issue acknowledged as a bug?

It is more of a missing feature, "the ability to stream large data to the 
backend."

> If yes, when is this issue going to be implemented in the code base?

There is an outstanding patch by Oliver Jowett, but I have some concerns 
about how it handles errror conditions (it will just drop the connection 
in some cases.)

> If it is already fixed, what are the steps to implement the changes to my
> 7.4.2 installation?  Build my own JDBC driver?

When/if it is applied it will go only into the 7.5 source tree so you can 
use that against your 7.4 server, but for the moment your only option is 
to build your own version of the driver.

The original patch/discussion is here:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&safe=off&threadm=Pin...

Kris Jurka



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: JDBC driver inserting into a table with Bytea type get
@ 2004-06-21 20:47  Sailer, Denis (YBUSA-CDR) <Denis.Sailer@Yellowbook.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Sailer, Denis (YBUSA-CDR) @ 2004-06-21 20:47 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc

Yes, there is talk of a patch going into CVS, but there isn't anything that
says "here it is".  Is there a patch in CVS and would someone post the
procedure for getting it out?

I don't see how this is a missing feature.  The documentation clearly states
that bytea can hold up to 1GB of data.  Isn't it fair to assume that each
interface that can be used to insert that data would work correctly?

Wouldn't the regression tests that get performed as part of each version
rollout catch this kind of error?  Binary data is so common in databases
these days.

If you couldn't tell by the questions, we are attempting to convert several
Oracle and DB2 databases to PostgreSQL.  The storage of documents is
critical to getting this done.  Up to this point my only worry was how to
deal with no point in time recovery.  I kind of expected basic functionality
to just work.


-----Original Message-----
From: Kris Jurka [mailto:books@ejurka.com] 
Sent: Monday, June 21, 2004 2:02 PM
To: Sailer, Denis (YBUSA-CDR)
Cc: 'pgsql-jdbc@postgresql.org'
Subject: Re: [JDBC] JDBC driver inserting into a table with Bytea type gets
out of me mory error.



On Mon, 21 Jun 2004, Sailer, Denis (YBUSA-CDR) wrote:

> This person was getting out of memory conditions inserting rows when the
> data in the bytea field was larger than approx.  1400 Kb.  This person had
> posted a fix to the group that seemed to work for him.  The inserts were
> coming from a java application using the JDBC driver.
> I just tried the latest JDBC driver and the problem still exists.
> Is this issue acknowledged as a bug?

It is more of a missing feature, "the ability to stream large data to the 
backend."

> If yes, when is this issue going to be implemented in the code base?

There is an outstanding patch by Oliver Jowett, but I have some concerns 
about how it handles errror conditions (it will just drop the connection 
in some cases.)

> If it is already fixed, what are the steps to implement the changes to my
> 7.4.2 installation?  Build my own JDBC driver?

When/if it is applied it will go only into the 7.5 source tree so you can 
use that against your 7.4 server, but for the moment your only option is 
to build your own version of the driver.

The original patch/discussion is here:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&safe=off&threadm
=Pine.BSO.4.56.0405251012470.21539%40leary.csoft.net&rnum=1&prev=/&frame=on

Kris Jurka



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: JDBC driver inserting into a table with Bytea type get
@ 2004-06-21 21:19  Kris Jurka <books@ejurka.com>
  parent: Sailer, Denis (YBUSA-CDR) <Denis.Sailer@Yellowbook.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Kris Jurka @ 2004-06-21 21:19 UTC (permalink / raw)
  To: Sailer, Denis (YBUSA-CDR) <Denis.Sailer@Yellowbook.com>; +Cc: pgsql-jdbc



On Mon, 21 Jun 2004, Sailer, Denis (YBUSA-CDR) wrote:

> Yes, there is talk of a patch going into CVS, but there isn't anything that
> says "here it is".  Is there a patch in CVS and would someone post the
> procedure for getting it out?

It is not in cvs.  It is the first post in this long thread.  Specifically 
this one:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&safe=off&selm=4085F2...

> I don't see how this is a missing feature.  The documentation clearly states
> that bytea can hold up to 1GB of data.  Isn't it fair to assume that each
> interface that can be used to insert that data would work correctly?

This will work correctly if you have adequate memory settings for the JVM.  
In reality not many have that amount of memory handy.  For example calling
PreparedStatement.setBytes() with a 1GB byte array requires at least 1GB
of memory and there's no getting around that.  The driver then does some
escaping and so on which takes additional memory.  The goal of this patch
is to reduce this additional overhead, but there's no way (even with the
patch) that you can have a 1GB byte array with the default JVM settings.  
The patch allows setBinaryStream to directly stream binary data which 
should get rid of out of memory errors, but it's not as friendly an 
interface.

Kris Jurka




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: JDBC driver inserting into a table with Bytea type get
@ 2004-06-21 22:50  Kris Jurka <books@ejurka.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Kris Jurka @ 2004-06-21 22:50 UTC (permalink / raw)
  To: pgsql-jdbc


On Mon, 21 Jun 2004, Sailer, Denis (YBUSA-CDR) wrote:

> I did not mean to imply that we are loading blobs that are 1GB in size.  We
> can't even get one loaded that is 1.5 MB, even when we specify jvm size of 1
> GB.  Yeah that's gigabytes.  If this thing was working correctly there
> wouldn't be any need for the posts that we've seen and 1GB jvm size would
> certainly handle a blob of 1.5MB

I didn't realize how bad this was until I tried using the attached test 
program.  With the default settings the driver can't load a 2MB byte 
array, but I don't agree with your claims of increasing jvm size not 
helping.  With -Xmx128M I was able to load the 2MB array, but not 3MB 
which is pretty scary (128 MB can't load 3MB of data?).  With the patched 
version of the driver and default memory settings I was able to load a 
25MB array before I started to swap badly as the postgresql backend was 
taking up a fair amount of memory in addition to the other things I've got 
running.

Getting this patch applied has jumped up many notches on my todo list 
because of this.

Kris Jurka

Attachments:

BinStream.java (text/plain, 766B) download import java.sql.*; import java.io.*; public class BinStream { public static void main(String args[]) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5750/jurka","jurka",""); int sizes[] = {1,2,3,4,5,6,7,8,9,10}; Statement stmt = conn.createStatement(); stmt.execute("CREATE TEMP TABLE bytes(a bytea)"); stmt.close(); for (int i=0; i<sizes.length; i++) { System.err.println("Testing with "+ sizes[i]); PreparedStatement pstmt = conn.prepareStatement("INSERT INTO bytes(a) VALUES (?)"); byte arr[] = new byte[sizes[i]*1000000]; pstmt.setBytes(1,arr); pstmt.executeUpdate(); pstmt.close(); } conn.close(); } }
^ permalink raw reply [nested|flat] 6+ messages in thread


end of thread, other threads:[~2004-06-21 22:50 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-06-21 16:44 JDBC driver inserting into a table with Bytea type gets out of me mory error. Sailer, Denis (YBUSA-CDR) <Denis.Sailer@Yellowbook.com>
2004-06-21 16:55 ` Re: JDBC driver inserting into a table with Bytea type gets Dave Cramer <pg@fastcrypt.com>
2004-06-21 19:02 ` Re: JDBC driver inserting into a table with Bytea type gets Kris Jurka <books@ejurka.com>
2004-06-21 20:47 Re: JDBC driver inserting into a table with Bytea type get Sailer, Denis (YBUSA-CDR) <Denis.Sailer@Yellowbook.com>
2004-06-21 21:19 ` Re: JDBC driver inserting into a table with Bytea type get Kris Jurka <books@ejurka.com>
2004-06-21 22:50 Re: JDBC driver inserting into a table with Bytea type get Kris Jurka <books@ejurka.com>

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