[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3586) SequenceHiLoGenerator generates values ahead of the actual sequence

Krasimir Chobantonov (JIRA) noreply at atlassian.com
Fri Mar 26 01:58:32 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3586?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=35964#action_35964 ] 

Krasimir Chobantonov commented on HHH-3586:
-------------------------------------------

Robin,

That is the problem - the multiplication takes the id to go far more that it is allowed - it is not in the range of the "reserved" ids. 

in the above code you are basically saying that the id that have to be generated is equal to the current sequence number multiplied by the step + 1 - imagine that the current sequece is 1000 and the step is 50 then the next generated id should be in the range of 1000 and 1050 but because of the multiplication you will end up with the following result

id = 1000 * (50 + 1) = 51000

as you see the 51000 is far more ahead than the 1050 limit - and yes in cluster environment you will have a big problem with that ... in a single machine env you will just "eat" the much more ids and you will see huge "holes" in the ids that are beeing generated.

Krasimir

> SequenceHiLoGenerator generates values ahead of the actual sequence
> -------------------------------------------------------------------
>
>                 Key: HHH-3586
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3586
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.3.1
>         Environment: Hibernate 3.3.1, Oracle 10G
>            Reporter: Krasimir Chobantonov
>   Original Estimate: 1 hour
>  Remaining Estimate: 1 hour
>
> The code that needs to be change in on line 83 of the SequenceHiLoGenerator
> here is the line
> 			hi = hival * ( maxLo+1 );
> basically we should add (+) the maxLo +1 to the current sequence value represented bu the hival instead of using multiply (*)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list