-->
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.  [ 1 post ] 
Author Message
 Post subject: SequenceGenerator(allocationSize=1) leads to huge contention
PostPosted: Fri Dec 04, 2009 9:04 pm 
Beginner
Beginner

Joined: Thu Jul 08, 2004 8:56 am
Posts: 23
Hi all,

I want to describe one thing that I fell it could be improved on Hibernate.
When an entity is configured to use @SequenceGenerator and its allocationSize is set to 1, Hibernate generates ids through SequenceHiLoGenerator as if it were using the regular SequenceGenerator but with one HUGE difference, SequenceHiLoGenerator generate method is synchronized since it was designed with the memory trick in mind. But the problem is, when there is a huge insert load it becomes a REALLY HUGE bottleneck (that can be identified with thread dumps). By huge load I say >100 concurrent inserts (that I guess is not that huge).
I sincerely think that Hibernate should fallback to "sequence" instead of "seqhilo" on those scenarios or at least warn the user on the console since it is really awkward to prefer having a synchronized implementation on something that can be potential slow under huge load scenarios than having an implementation that is not synchronized.

I really wanted to share this since it gave us an enormous headache recently (we switched this huge load entity to use a greater allocationSize and "fixed" the sequence but we are manually switching to "sequence" using @GenericGenerator for the rest).

What you guys (users and Hibernate developers) think about this? Wasn't it better to have it defaulted to the regular SequenceGenerator on those cases?

Best regards,
Rafael Ribeiro

I'll paste the links to SequenceHiLoGenerator.java and SequenceGenerator.java for anyone willing to look and check what I said:
http://anonsvn.jboss.org/repos/hibernate/core/tags/hibernate-3.3.1.GA/core/src/main/java/org/hibernate/id/SequenceHiLoGenerator.java
http://anonsvn.jboss.org/repos/hibernate/core/tags/hibernate-3.3.1.GA/core/src/main/java/org/hibernate/id/SequenceGenerator.java

_________________
Rafael Ribeiro


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

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.