Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: AllocationSize incrementBy causes constraint violations
PostPosted: Fri Feb 24, 2017 2:21 am 
Regular
Regular

Joined: Wed Jan 21, 2009 8:41 pm
Posts: 54
Increment by on our oracle sequence is 20, and historically allocationSize has been set to 50 and we've never had an issue.

Recently, I tried to align this with increment by and set it to 20.

In production, there are several instances of the same program running that will all share the same sequence. _SEQ

So, can the above result in constraint violations?


Top
 Profile  
 
 Post subject: Re: AllocationSize set to incrementBy caused constraint viol....
PostPosted: Fri Feb 24, 2017 3:50 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1038
If you're using the pooled or pooled-lo generator, then there shall be no problem because the sequence value is included in the upper or lower boundaries of the generated sequence values.

If you're using the hilo generator, then you could risk having collisions.

Best thing, just take a copy of the production database and test it on your local machine to see if you get those identifier conflicts.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: AllocationSize incrementBy causes constraint violations
PostPosted: Fri Feb 24, 2017 8:21 am 
Regular
Regular

Joined: Wed Jan 21, 2009 8:41 pm
Posts: 54
Using Hilo yes.

Sorry I was mistaken earlier. The increment by is only 1.

And I observe that I was getting negative values for the ID column in some instances.

So, question.

The risk of collisions exist when allocationSize (20) = "increment by" (1) of Oracle Sequence?

There was no risk of collision when allocationSize (50) > "increment by" (1)

The batch insert size I have is actually 50

Unfortunately it's not possible to copy production and I wasn't able to reproduce
the behavior outside of production.

So it seems like by reducing the allocationSize from 50 to 20 I invited collisions with values that were already used on the day. I didn't see these collisions in UAT because I don't
have enough data there for a collision to occur.


Top
 Profile  
 
 Post subject: Re: AllocationSize incrementBy causes constraint violations
PostPosted: Fri Feb 24, 2017 12:38 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1038
If I were you, I would not change the allocationSize unless you fell that you'll run out of identifiers.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 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.