-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Transaction with Blobs - System halts at commit
PostPosted: Mon May 05, 2008 9:38 am 
Newbie

Joined: Mon May 05, 2008 9:23 am
Posts: 2
Location: Brasilia - Brazil
Hi everyone,

I have a transaction which includes adding 5 records in a table, which includes a Blob (pdf file) as one of its columns.

The tables are in an oracle database. I'm using tomcat 6 as app server and Hibernate for persistence framework.

When i run my application, the system halts when i try to commit the transaction.

When i run the same transaction in PL/SQL, connecting with the same oracle user, the transaction runs and commits in less than one second.

Could anyone please help me with this? Why does the system halt when i call Transaction.commit()?

_________________
Henrique Ordine


Top
 Profile  
 
 Post subject: Oracle's Batching might be an issue
PostPosted: Wed May 07, 2008 4:14 pm 
Newbie

Joined: Fri Dec 21, 2007 11:29 am
Posts: 2
Hello,

Your post didn't give a lot of details about what you mean by "system halts at commit" so this solution may or may not apply.

We also stored PDF files in a BLOB column. We found that if we were trying to insert large BLOBs or multiple BLOBs, the database session would hang. It would never call commit, and from the database's perspective, the session was hanging open but not busy (no SQL was being executed). From the Java side, I'd have to restart the web app to kill the connection off.

I enabled uber-logging on the database tier and was able to see that the final log statement issued before the connection hung was
"DEBUG org.hibernate.jdbc.AbstractBatcher - Executing batch size: 2".
Armed with the knowledge that batching might be the issue, I was able to do much better google searches and turned up other users reporting the same error.

I investigated batching, and here's what I learned about it: Starting with Oracle 8, Oracle's JDBC driver gave users the ability to "batch" database requests within a single transaction. If the Java code detected that multiple statements would be issued inside a single transaction, the JDBC driver would batch them up until a batch limit was reached, and then would send all the statements as single group to the database. The default seems to be set to 10 statements in a batch. This does have a performance improvement if you are doing many statements in a transaction, especially in a high-throughput system.

Unfortunately, this feature seems to be buggy with respect to BLOBs and CLOBs ever since it was introduced in version 8.

So what was happening is that we would issue a handful of update statements in a single transaction including several for each of the BLOBs. Oracle's batching would 'hold' them until the batch limit of 10 was reached, or the transaction commit was issued, ... and then just hang, never to come back to life again.

Our solution was to disable JDBC batching and force each statement to be sent to the server one at a time - this can be done via the Hibernate configuration like so:
<property name="hibernate.jdbc.batch_size">0</property>

Hope this helps,
Tara


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 07, 2008 4:33 pm 
Newbie

Joined: Mon May 05, 2008 9:23 am
Posts: 2
Location: Brasilia - Brazil
Tara, it worked!
Your post was very informative and clear.
Thank you so much.
You have a beautiful name, by the way. :)

_________________
Henrique Ordine


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.